Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi, cant you help me solve this question? Thank you Suppose that inside the main

ID: 3790529 • Letter: H

Question

Hi, cant you help me solve this question? Thank you

Suppose that inside the main method below you decide to create a Scanner object, and then read in an int and then a double on one line, where the two values are separated by a space, e.g. 19 3.7778 Complete the main method below for doing this chore. Notice that we've constructed a Scanner object for you-be sure to use this object. You should store the integer in an int variable called n, and the double value in a double variable called r. (Note that both of these variables have already been declared). Finally, in the last statement in main, you should print the sum of these two values. import java. util Scanner; public class MyTest {public static void main(String[] args) {Scanner console = new Scanner (System. in); int n; double r;}//end main}//end class

Explanation / Answer

Program:


import java.util.Scanner;

public class MyTest {
   public static void main(String str[]){
       Scanner console=new Scanner(System.in);
       int n;
       double r;
       System.out.println("Enter value of integer n : ");
       n=console.nextInt();
       System.out.println("Enter value of double r : ");
       r=console.nextDouble();
       System.out.println("Sum of two number n and r : "+(n+r));
      
   }//end main
}//end class

Result:

Enter value of integer n :
5
Enter value of double r :
7.4
Sum of two number n and r : 12.4

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote