Question

Hi. Intro Java hw help needed; Update an existing Java program that inputs two integers and...

Hi.
Intro Java hw help needed;



Update an existing Java program that inputs two integers and outputs their sum, quotient and remainder by adding code to also output the difference and product.

Hi.Intro Java hw help needed;Update an existing Ja
Hi.Intro Java hw help needed;Update an existing Ja
0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;
import java.lang.*;
import java.io.*;


class Hwk3
{
public static void main (String[] args) throws java.lang.Exception
{
  int integer1,integer2,result,quotient,remainder;
  Scanner stdin=new Scanner(System.in);
  System.out.println("Calculator");
  System.out.println("Enter two Integers");
  integer1=stdin.nextInt();
  integer2=stdin.nextInt();
  System.out.println("Integer1= "+integer1 +"   Integer2= "+integer2);
  System.out.println("Enter Option\n 1. Addition\n 2.Subtraction\n 3. Multiplication\n 4. Division");
  int option=stdin.nextInt();
  switch(option)
  {
   case 1: result=integer1+integer2;
           System.out.println("Addition Of two integers= "+result);
           break;
   case 2: result=integer1-integer2;
           System.out.println("Subtraction Of two integers= "+result);
           break;
   case 3: result=integer1*integer2;
           System.out.println("Multiplication Of two integers="+result);
           break;
   case 4: quotient=integer1/integer2;
           remainder=integer1%integer2;
            System.out.println("Quotient Of two integers= "+quotient);
             System.out.println("Remainder Of two integers= "+remainder);
           break;
   default: System.out.println("Enter the correct choice");
            break;
  }
  
}
}

output

a) addition,if option =1

Success time: 0.05 memory: 711680 signal:0

Calculator
Enter two Integers
Integer1=  78   Integer2=  35
Enter Option
  1. Addition
  2.Subtraction
 3. Multiplication
 4. Division
Addition Of two integers=  113

b)subtraction ,if option =2
Success time: 0.07 memory: 711680 signal:0
Calculator
Enter two Integers
Integer1=  78   Integer2=  35
Enter Option
 1. Addition
  2.Subtraction
 3. Multiplication
 4. Division
Subtraction Of two integers=  43


c)multiplication,option=3
if option=3
Success time: 0.06 memory: 711680 signal:0
Calculator
Enter two Integers
Integer1=  78   Integer2=  35
Enter Option
 1. Addition
  2.Subtraction
 3. Multiplication
 4. Division
Multiplication Of two integers=2730

d)division,option=4

  • Success time: 0.06 memory: 711680 signal:0

    Calculator
    Enter two Integers
    Integer1=  78   Integer2=  35
    Enter Option
     1. Addition
      2.Subtraction
     3. Multiplication
     4. Division
    Quotient Of two integers=  2
    Remainder Of two integers=  8

e) if option is not between 1 and 4

  • Success time: 0.06 memory: 711680 signal:0

    Calculator
    Enter two Integers
    Integer1=  78   Integer2=  35
    Enter Option
     1. Addition
      2.Subtraction
     3. Multiplication
     4. Division
    Enter the correct choice


answered by: ANURANJAN SARSAM
Add a comment
Know the answer?
Add Answer to:
Hi. Intro Java hw help needed; Update an existing Java program that inputs two integers and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT