Create a Java application InputAndArithmetic that uses a Scanner object to do the following: 1. Ask the user to enter an integer using prompt "Enter an integer: " 2. Get the integer and store it in an integer variable 3. Print the integer on a new line 4. Ask the user to enter another integer using prompt "Enter a second integer: 5. Get the second integer and store it in another integer variable 6. Print the second integer on a new line 7. Calculate the product of the two integers 8. Print the product on a new line 9. Calculate the double quotient of the first integer divided by the second 10. Print the double quotient on a new line. 11. Calculate the integer quotient of the first integer divided by the second 12. Print the integer quotient on a new line. 13. Calculate the remainder of the first integer divided by the second 14. Print the remainder on a new line. 11 Sample output Enter an integer: 3 The first integer is 3. Enter a second integer: The second integer is 5. The product of the two integers is 15. The double quotient of the first integer divided by the second integer is 0.6. The integer quotient of the first integer divided by the second integer is 0. The remainder of the first integer divided by the second integer is 3. You should create just one Scanner object. 5

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter6: Looping
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question
Must used multiple Scanner objects
Create a Java application InputAndArithmetic that uses a Scanner object to do the
following:
1. Ask the user to enter an integer using prompt "Enter an integer:
2. Get the integer and store it in an integer variable
3. Print the integer on a new line
4. Ask the user to enter another integer using prompt "Enter a second integer: "
5. Get the second integer and store it in another integer variable
6. Print the second integer on a new line
7. Calculate the product of the two integers
8. Print the product on a new line
9. Calculate the double quotient of the first integer divided by the second
10. Print the double quotient on a new line.
11. Calculate the integer quotient of the first integer divided by the second
12. Print the integer quotient on a new line.
13. Calculate the remainder of the first integer divided by the second
14. Print the remainder on a new line.
Sample output
Enter an integer: 3
The first integer is 3.
Enter a second integer:
The second integer is 5.
The product of the two integers is 15.
The double quotient of the first integer divided by the second integer is
0.6.
The integer quotient of the first integer divided by the second integer is 0.
The remainder of the first integer divided by the second integer is 3.
You should create just one Scanner object.
Codecheck link for Problem B
Problem C
Write a Java program StringProg which creates a Scanner and then does the following:
Transcribed Image Text:Create a Java application InputAndArithmetic that uses a Scanner object to do the following: 1. Ask the user to enter an integer using prompt "Enter an integer: 2. Get the integer and store it in an integer variable 3. Print the integer on a new line 4. Ask the user to enter another integer using prompt "Enter a second integer: " 5. Get the second integer and store it in another integer variable 6. Print the second integer on a new line 7. Calculate the product of the two integers 8. Print the product on a new line 9. Calculate the double quotient of the first integer divided by the second 10. Print the double quotient on a new line. 11. Calculate the integer quotient of the first integer divided by the second 12. Print the integer quotient on a new line. 13. Calculate the remainder of the first integer divided by the second 14. Print the remainder on a new line. Sample output Enter an integer: 3 The first integer is 3. Enter a second integer: The second integer is 5. The product of the two integers is 15. The double quotient of the first integer divided by the second integer is 0.6. The integer quotient of the first integer divided by the second integer is 0. The remainder of the first integer divided by the second integer is 3. You should create just one Scanner object. Codecheck link for Problem B Problem C Write a Java program StringProg which creates a Scanner and then does the following:
Expert Solution
Java Program

import java.util.Scanner;
public class InputAndArithmetic
{
 public static void main(String[] args) 
 {
     int num1, num2;
     Scanner sc1 = new Scanner(System.in);
     Scanner sc2 = new Scanner(System.in);
     
  System.out.print("Enter an integer: ");
  num1 = sc1.nextInt();
  System.out.print("The first integer is " + num1 + ".");
  
  System.out.print("\nEnter a second integer: ");
  num2 = sc2.nextInt();
  System.out.print("The second integer is " + num2 + ".");
  
  int product = num1*num2;
  System.out.print("\nThe product of the two integers is " + product + ".");
  
  double quotient1 = (double)num1/num2;
  System.out.print("\nThe double quotient of the first integer divided by the second integer is " + quotient1 + ".");
  
  int quotient2 = num1/num2;
  System.out.print("\nThe integer quotient of the first integer divided by the second integer is " + quotient2 + ".");
  
  int remainder = num1%num2;
  System.out.print("\nThe remainder of the first integer divided by the second integer is " + remainder + ".");
  
 }
}

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT