Write a Java program that will prompt the user to enter an integer, use the Scanner class to read the integer and save it in a variable named ‘count’, then increase the integer value by 3 and display the result on the screen. Without using Eclipse, what is the output produced by the following lines of program code? (Trace the result using the State Diagram) int quotient = 7/3: int remainder = 7% 3: System.out.println(“quotient = ” + quotient): System.out.printin(“remainder = ” + remainder);
Expert Answer
Ex:1
package org.students;
import java.util.Scanner;
public class DisplayCount {
public static void main(String[] args) {
// Declaring variable
int count;
/*
* Creating an Scanner class object which is used to get the inputs
* entered by the user
*/
Scanner sc = new Scanner(System.in);
// Getting the input entered by the user
System.out.print(“Enter an Integer :”);
count = sc.nextInt();
count = count + 3;
// Displaying the output
System.out.println(“The count :” + count);
}
}
_______________________
Output:
Enter an Integer :10
The count :13
____________________
Ex:2:)
Ans)
Output:
quotient = 2
remainder = 1