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

Q1. Program Description : The program should: Ask a user to enter some digit (in

ID: 3788600 • Letter: Q

Question

Q1. Program Description: The program should:

Ask a user to enter some digit (integer) between 1 and 9

Multiply it by 9

Write the output to the screen

Multiply that new number by 12345679 (note the absence of the number 8)

Write that output to the screen.

As shown below, the program should print out the entire multiplication as though you had done it by hand.

Presents the output of two different input other than 5 in the Word doc.

-------------------Sample Screen Output:----------------------

Enter a number from 1 to 9: 5

5

X 9

----------------

45

X          12345679

---------------------

555555555   (ßTo look like this, the last number must be an int.)

Note: Your alignment does not need to be perfect, but should roughly approximate what you see above.

---------------------------------------------------------------------

Q2. Program Description: Write a program that prompts the reader for two integers and then prints:

The sum

The difference (This should be number1 minus number2.)

The product

The average (This should be a double number. with decimal point)

Presents the output of two different input sets in the Word doc.

--------------Sample Screen Output:------------------

Enter number 1:   13

Enter number 2:   20

Original numbers are 13 and 20.

Sum =             33

Difference =      -7

Product =         260

Average =         16.5

Explanation / Answer

Ques 1

import java.util.Scanner;


public class Example1 {
   public static void main(String args[]){
       Scanner sc = new Scanner(System.in);
       System.out.print("Enter a number from 1 to 9:");
       int a = sc.nextInt();
       System.out.println("");
       int finalans;
       finalans = a*9;
       System.out.println(" "+a);
       System.out.println("X "+9);
       System.out.println("-------------------");
       System.out.println(" "+finalans );
       System.out.println("x "+12345679);
       System.out.println("-------------------");
       System.out.println(" "+finalans*12345679);
   }
}

Ques 2

import java.util.Scanner;


public class Example1 {
   public static void main(String args[]){
       Scanner sc = new Scanner(System.in);
       System.out.print("Enter number 1:");
       int a = sc.nextInt();
       System.out.print("Enter number 2:");
       int b =sc.nextInt();
       System.out.println("Original numbers are "+a+ " and "+b);
       System.out.println("Sum = "+(a+b));
       System.out.println("Difference = "+(a-b));
       System.out.println("Product = "+a*b);
       System.out.println("Average = "+(a+b)/2);
   }
}