Question

In: Computer Science

USING jgrasp environment, javascript rite a complete program that prompts the user for two integers and...

USING jgrasp environment, javascript

rite a complete program that prompts the user for two integers and then prints the following report to the screen, exactly as shown. example, using 23 and 18 as the user input:

your numbers are :23 and 18

sum=41

product=414

use the scanner class nextlnt() method to read the user's numbers: scanner keyboard... ...keyboard.nextlnt()

Solutions

Expert Solution

Thanks for the question.

Here is the completed code for this problem. Comments are included so that you understand whats going on. Let me know if you have any doubts or if you need anything to change.

Thank You !!

=================================================================================================

import java.util.Scanner;

public class Arithmetic {


    public static void main(String[] args) {


        Scanner keyboard = new Scanner(System.in);
        System.out.print("Enter two numbers separated by space: ");
        int firstNum, secondNum;
        //use the scanner class nextlnt() method to read the user's numbers
        firstNum = keyboard.nextInt(); //keyboard... ...keyboard.nextlnt()
        secondNum=keyboard.nextInt(); //keyboard... ...keyboard.nextlnt()

        System.out.println("Your numbers are : "+firstNum+" and "+secondNum);
        System.out.println("sum="+(firstNum+secondNum));
        System.out.println("product="+(firstNum*secondNum));
    }
}


Related Solutions

jgrasp environment, java write a complete program that prompts the user to enter their first name,...
jgrasp environment, java write a complete program that prompts the user to enter their first name, middle name, and last name (separately). print out thier name and initials, exactly as shown: your name is: John Paul Chavez your initials are: J. P. C. use string method chartAt() to extract the first (zero-th) character from a name(the name is a string type): username.charAt(0). thank you.
jgrasp environment, java write a complete program that calculates a restaurant bill. Prompt the user for...
jgrasp environment, java write a complete program that calculates a restaurant bill. Prompt the user for the check amount, then ask the user what type of tipp they would like to leave: the choices are 1 for good tip (20%), 2 for an average tip (15%), or 3 for poor tip (10%). Use their input and an if-else to calculate the tip amount. Then calculate and output the final bill: check+tip print out the bill, exactly as shown (print the...
You are required to write an interactive program that prompts the user for two integers X...
You are required to write an interactive program that prompts the user for two integers X and Y and performs the following tasks: Adds two numbers Subtracts Y from X Multiplies X and Y Divides X by Y Finds which numbers is larger X oy Y) Prints all the results (a , b, c, d, and e) Program requirements: -     The program should run as many times as the users wish -     The program should be fully documented. -   ...
Write a program that prompts user to enter integers one at a time and then calculates...
Write a program that prompts user to enter integers one at a time and then calculates and displays the average of numbers entered. Use a while loop and tell user that they can enter a non-zero number to continue or zero to terminate the loop. (Switch statement) Write a program that prompts user to enter two numbers x and y, and then prompts a short menu with following 4 arithmetic operations: Chose 1 for addition Chose 2 for subtraction Chose...
TO BE DONE IN JAvA Complete the calculator program so that it prompts the user to...
TO BE DONE IN JAvA Complete the calculator program so that it prompts the user to enter two integers and an operation and then outputs the answer. Prompt the user three times, don't expect all the inputs on one line. Possible operations are + - * / No other words or symbols should be output, just the answer. Requested files import java.util.Scanner; /** * This is a simple calculator Java program. * It can be used to calculate some simple...
Problem description Write a C++ program that prompts the user to enter two non-negative integers, firstNum...
Problem description Write a C++ program that prompts the user to enter two non-negative integers, firstNum and secondNum. The program then prints all palindromic primes (Links to an external site.) between firstNum and secondNum, inclusive. A palindromic number is a number whose digits are the same forward or backward (e.g., 12321). A palindromic prime is a prime number that is also a palindromic number (e.g., 101). You must implement and use the following functions as prototyped below: /// --------------------------------------------------------------- ///...
C++ Write a program that prompts the user to enter 50 integers and stores them in...
C++ Write a program that prompts the user to enter 50 integers and stores them in an array. The program then determines and outputs which numbers in the array are sum of two other array elements. If an array element is the sum of two other array elements, then for this array element, the program should output all such pairs separated by a ';'. An example of the program is shown below: list[0] = 15 is the sum of: ----------------------...
C Program 1. Write a program that prompts the user to enter 3 integers between 1...
C Program 1. Write a program that prompts the user to enter 3 integers between 1 and 100 from the keyboard in function main and then calls a function to find the average of the three numbers. The function should return the average as a floating point number. Print the average from main.The function header line will look something like this:float average(int n1, int n2, int n3) STOP! Get this part working before going to part 2. 2. Create a...
1. Write an assembly language program that prompts the user for and reads four integers (x1,...
1. Write an assembly language program that prompts the user for and reads four integers (x1, y1, x2, y2) which represent the coordinates of two points. Make sure you keep track of which number is which. 2. Treat the line between the points as the radius of a sphere and compute the surface area of the sphere. Print the output with a label, such as “The surface area of the sphere is: …”. Hint: The distance between the points is...
Write a complete C++ program that prompts the user for and takes as input, numbers until...
Write a complete C++ program that prompts the user for and takes as input, numbers until the user types in a negative number. the program should add all of the numbers together. Then if the result is less than 20 the program should multiply the result by 3, otherwise subtract 2 from the result. Finally, the program should printout the result.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT