Question
Q2. For the following questions use switch statements. You need to write just few lines of java codes (no class or method codes needed): [2x5=10]
Q2. For the following questions use switch statements. You need to write just few lines of java codes (no class or method codes needed): [2x5=10]
a. Write Java codes to implement the following problem: if the user enters 5 cents the system prints 5 cents added, if the user enters 10 cents the system prints 10 cents added, if the user enters 25 cents the system prints 25 cents added, if the user enters 1 dollar the system prints 100 cents added. If the user enters other coins then print Entered coin not supported. b. Write java codes to implement the following problem: if the user enters A then call the calculator method add (Calculator.add(val1, val2)), if the user enters M then call the calculator method multiply (Calculator.mult(val1, val2)), if the user enters D then call the calculator method divide (Calculator.divide(val1, val2)), if the user enters S then call the calculator method subtract (Calculator.subtract(val1, val2)), and If the user enters other characters then print Code not supported.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started