Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the code to use the switch statement. Modify the code to use the switch statement. package lab2; import java.util.Scanner; public class Q3 { public

Modify the code to use the switch statement.

image text in transcribedModify the code to use the switch statement.

package lab2; import java.util.Scanner; public class Q3 \{ public static void main(String[] args) \{ Scanner console= new Scanner(System.in); int option; double amount, balance = 23500.0; System.out.println("1: Withdrawalln2: Depositln3: Check balance "); System.out.print( "Please enter you selection (1, 2, or 3): "); option=console.nextInt(); if (option ==1) \{ System.out.println( "Enter amount to withdraw: "); amount=console.nextDouble(); balance -= amount; System.out.println( "Your balance is: " + balance ); \} else if (option ==2) \{ System.out.println( "Enter amount to deposit: "); amount=console.nextDouble(); balance += amount; System.out.println( "Your balance is: " + balance ); } else if (option == 3) System.out.println( "Your balance is: " + balance ); else System.out.println("Remove card " ); \}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data And Hadoop Fundamentals Tools And Techniques For Data Driven Success

Authors: Mayank Bhushan

2nd Edition

9355516665, 978-9355516664

More Books

Students also viewed these Databases questions