Finish the following Java program so that it outputs the sum, difference, produc
ID: 3787281 • Letter: F
Question
Finish the following Java program so that it outputs the sum, difference, product, integer quotient, modulus and real number quotient of two random integers: import java.util.*;//brings in Random & Scanner public class L2p3 {public static void main (String [] args) {int randVall, //2 random numbers randVal2;//generated by program Random rg = new Random();//random generator randVall = rg.nextlnt (100)+1;//number between 1 & 100 randVal2 = rg.nextInt (50) +1;//number between 1 & 50 System.out.println ("The numbers are: " + randVall + " and " + randVal2);//find & print sum: int sum - randVall + randVal2; System.out.println ("The sum is: " + sum);//****************** YOUR CODE HERE ******************}//end of main}}//end of classExplanation / Answer
The below program shows the product,difference, integer quotient, module of two random number integers
import java.util.*;
public class L2p3
{
public static void main(string [] args)
{
int randval1,
randval2;
random rg= new random();
randval1=rg.nextint(100)+1;
randval2=rg.nextint(50)+1;
system.out.println("the numbers are:" randval1+ 'and'+ randval2);
int sum= randval1+ randval2;
system.out.println(" The sum is:" + sum);
// difference between the Random values
int diff;
s.o.p(the differnce of'+randval1+"and"+randval2);
return randval1.compare to (randval2);
s.o.p(the differnce of'+randval1+"and"+randval2+ "is"+ diff);
// product between the random values
int product= randval1* randval2;
system.out.println(" The product is:" + product);
// quotient between the random values
int q=randomval1/randomval2;
system.out.println(" The quotient is:" + q);
// modulous between the random values
int m=randomval1%randomval2;
system.out.println(" The modulous is:" + m);
}
output:
the sum is:
the product is:
the difference is:
the quotient is:
the modulous is:
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.