Computer Applications
Using the switch statement in Java, write a program to display the name of the city according to the user's choice.
D — Delhi, M — Mumbai, K — Kolkata, C — Chennai
Java
Java Conditional Stmts
10 Likes
Answer
import java.util.Scanner;
public class KboatCityName
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter your choice: ");
char ch = in.next().charAt(0);
switch (ch) {
case 'D':
System.out.println("Delhi");
break;
case 'M':
System.out.println("Mumbai");
break;
case 'K':
System.out.println("Kolkata");
break;
case 'C':
System.out.println("Chennai");
break;
default:
System.out.println("Invalid choice");
}
}
}
Output
Answered By
1 Like
Related Questions
Admission in a professional course is subject to the following criteria:
- Marks in Physics >= 70
- Marks in Chemistry >= 60
- Marks in Mathematics >= 70
- Total marks in all subjects >= 225
Or
Total marks in Physics and Mathematics >= 150
Write a program in Java to accept marks in these 3 subjects (Physics, Chemistry, and Mathematics) and display if a candidate is eligible.
Write a program that will read the value of x and compute the following function:
Write a program that reads a month number and displays it in words.
Employees at Arkenstone Consulting earn the basic hourly wage of Rs.500. In addition to this, they also receive a commission on the sales they generate while tending the counter. The commission given to them is calculated according to the following table:
Total Sales Commmision Rate Rs. 100 to less than Rs. 1000 1% Rs. 1000 to less than Rs. 10000 2% Rs. 10000 to less than Rs. 25000 3% Rs. 25000 and above 3.5% Write a program in Java that inputs the number of hours worked and the total sales. Compute the wages of the employees.