In: Computer Science
This is a Java program
Problem Description
Write an application that inputs five digits from the user, assembles the individual digits into a five-digit integer number (the first digit is for one’s place, the second digit is for the ten’s place, etc.) using arithmetic calculations and prints the number. Assume that the user enters enough digits.
Sample Output
Enter five digits: 1 2 3 4 5
The number is 54321
Problem-Solving Tips
Project1_ AssembleDigits_YourName.java
Project1_Answers_YourName.docx.
Follow-Up Questions and Activities
Problem Description
Write an application that inputs five digits from the user, assembles the individual digits into a five-digit integer number (the first digit is for one’s place, the second digit is for the ten’s place, etc.) using arithmetic calculations and prints the number. Assume that the user enters enough digits.
Sample Output
Enter five digits: 1 2 3 4 5
The number is 54321
Problem-Solving Tips
Project1_ AssembleDigits_YourName.java
Project1_Answers_YourName.docx.
Follow-Up Questions and Activities
Project1_ AssembleDigits_YourName.java
import java.util.Scanner;
public class Project1_AssembleDigits_YourName {
public static void main(String[] args) {
// Scanner class object to get the
input from user
Scanner input=new
Scanner(System.in);
System.out.print("Enter five
digits: ");
// accept five digits from
user
int one=input.nextInt();
int two=input.nextInt();
int three=input.nextInt();
int four=input.nextInt();
int five=input.nextInt();
// calculate the number
int
number=one+(two*10)+(three*100)+(four*1000)+(five*10000);
System.out.println("The number is
"+number); // print the number
input.close(); // close Scanner
object
}
}
Sample run 1
Sample run 2