Question
(1) Prompt the user to input one integer and one real number and output these two numbers. (2 pts) Enter an integer: 14 Enter a
(1) Prompt the user to input one integer and one real number and output these two numbers. (2 pts)
Enter an integer: 14 Enter a real number: 11.28 The inputs are: 14 and 11.28
(2) Convert the real number to integer and output the integer (2 pts)
11.25 to integer is: 11
(2) Perform division and modulus on these two integers and output the result (3 pts)
14 / 11 = 1 14 % 11 = 3
(3) Find the average of these two integers (3 pts)
average of 14 and 11 is 12.5
ive started it
import java.util.Scanner;
public class Main { public static void main(String[] args) { // declare variables int integerNum; double integerNum2;
//prompt for input Scanner scnr = new Scanner(System.in); System.out.println("Enter an integer: "); integerNum = scnr.nextInt(); System.out.println("Enter a real number: "); integerNum2 = scnr.nextDouble(); System.out.print("The inputs are: "); System.out.print(integerNum + " and " + integerNum2); //cast double to integer and output //Perform / and % and output the result
} }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started