Need help answering the following using java
2a. Write a java program (just a “void main”) that will reverse the digits of a user entered, positive three-digit number. You can assume the user enters an integer. Your code segment should first verify that the user has entered a number from 100 to 999 (error message if not). If the user has entered a three-digit number, output a new number with the original digits reversed.
2b. Instead of being limited to a 3 digit number, what if your previosu program had to revierse the digits of any integer? Discuss in detail how you would implement this, code not necessary.
2a)
Program:
import java.util.*;
class ReverseNumber
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
int num,rev,rem,i;
rev=0;
System.out.print("\nEnter a number: ");
num=input.nextInt();
if(num>=100 && num<=999)
{
for(i=1;i<=3;i++)
{
rem=num%10;
num=num/10;
rev=rev*10+rem;
}
System.out.println("\nReverse Number: "+rev);
}
else
{
System.out.println("\nPlease enter three digits number
only!!");
}
System.out.println("\n");
}
}
Output:

2b)
First, remove the if-else part of the program.
Next, use any loop but most preferable for this example is while loop and here there has to be a condition where the number has to be greater than 0 so while loop will be executed until the value of num becomes zero. and meanwhile, it will remove all the digit from number then store in rev variable.
sample Code:
while(num>0)
{
rem=num%10;
num=num/10;
rev=rev*10+rem
}
then print the value of rev;
Program:
import java.util.*;
class ReverseNumber
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
int num,rev,rem;
rev=0;
System.out.print("\nEnter a number: ");
num=input.nextInt();
while(num>0)
{
rem=num%10;
num=num/10;
rev=rev*10+rem;
}
System.out.println("\nReverse Number: "+rev);
System.out.println("\n");
}
}
Output:

Need help answering the following using java 2a. Write a java program (just a “void main”)...
How to write this code in C++???? using fstream Write a program which: Asks the user to enter a positive integer greater than 0 Validates that the entry is a positive integer Outputs the digits in reverse order with a space separating the digits Outputs the even digits not in reverse order with a space separating the digits (consider zero to be even) If there are no even digits, the an appropriate message should be displayed: There are no even...
Create Code Using C program: 1. Write a function, reverse Digit, that takes an integer as a parameter and returns the number with its digits reversed. For example, the value of reverseDigit (12345) is 54321; the value of reverse Digit (5600) is 65, the value of reverse Digit (7008) is 8007 and the value of reverse Digit (-532) is -235.
Program#3(17 points): write a java program (SunDigits) as follows The main method prompts the user to enter an integer number. The method then calls Method Sum (defined blew) to add the digits and return their total. The main method then prints the digits total with proper label as shown below Method Sum )is of type integer and takes an integer value. The method recursively adds up the digits and returns their total. Document your code and use proper prompts for...
Write a Java program to convert octal (integer) numbers into their decimal number equivalents (exactly the opposite of what you have done in Assignment 4). Make sure that you create a new Project and Java class file for this assignment. Your file should be named “Main.java”. You can read about octal-to-decimal number conversions on wikepedia Assignment 4 is at the bottom Objective Your program should prompt the user to enter a number of no greater than 8 digits. If the...
I need help with this assignment. Please include comments throughout the program. Thanks Develop an algorithm and write the program in java for a simple game of guessing at a secret five-digit code. When the user enters a guess at the code, the program returns two values: the number of digits in the guess that are in the correct position and the sum of those digits. For example, if the secret code is 13720, and the user guesses 83521, the...
Write an application (SpaceDigits) that: (in java) a. inputs one number consisting of five digits from the user, separates the number into its individual digits and prints the digits separated from one another by three spaces each. For example, if the user types in the number 42339, the program should print “4 2 3 3 9.” (Hint: The number input is five digits long, dividing it by 10000 gives the leftmost digit. digit1 = number / 10000 ) b. determines...
Using Visual Studio 2017 Create This Program Using C# implement source code Program 5: The concept of a 5-digit palindrome number is a 5-digit number that reads the same from left to right and from right to left. For example, 12121, 45454, and 14741 are valid 5-digit palindrome numbers. Design (pseudocode) and implement (source code) a program (name it FiveDigitPalindrom) that reads a 5-digit number from the user (as integer value, not string) and then mathematically (using division and remainder...
Jave eclipse Wanna help Program 1 Algorithm Problem statement: Write a Java program to add up the digits of a number entered by the user and output the result. You may not use an array top perform this task. The program should be able to handle an integer of any size. For example, if the number 1256 was entered, the sum would be: SumOfDigits = 1 + 2 + 5 + 6 = 14 Solution: The following Algorithm could be...
Write a python program that does the following. a. It asks the user to enter a 5-digit integer value, n. b. The program reads a value entered by the user. If the value is not in the right range, the program should terminate. c. The program calculates and stores the 5 individual digits of n. d. The program outputs a “bar code” made of 5 lines of stars that represent the digits of the number n. For example, the following...
Please write a java program with a input file "jabberwock.txt", and output the "output.txt" with following requirement. You and your partner will be writing a simple Java program that implements some basic file I/O operations. You can use this code as the basis for some of your next project. FIRST: Write code that prompts the user for the name of a text file, opens that file if it exists and reads the file one line at a time printing each...