** Write a Java Code **
1. Use for and switch statements
Write a for loop that counts from 1 to 5, and in the for loop body, use a switch statement to display a letter in the alphabet that corresponds to the number (i.e., 1 is A, 2 is B, etc.).
public class MyExample
{
//main method
public static void main(String args[])
{
//for loop iteration from 1 to 5
for(int i=1;i<=5;i++)
{
//switch case
switch(i)
{
// if 'i' is 1
case 1: System.out.println('A');
break;
// if 'i' is 2
case 2: System.out.println('B');
break;
// if 'i' is 3
case 3: System.out.println('C');
break;
// if 'i' is 4
case 4: System.out.println('D');
break;
// if 'i' is 5
case 5: System.out.println('E');
break;
}//end of switch case
}//end of for loop
}//end of main method
}//end of class


** Write a Java Code ** 1. Use for and switch statements Write a for loop...
hello. i need help with number 2
ONLY
1. Use if statements to write a Java program that inputs a single letter and prints out the corresponding digit on the telephone. The letters and digits on a telephone are grouped this way 2=ABC 3 = DEF 4 GHI 5 JKL 6 - MNO 7 - PRS 8 - TUV 9-WXY No digit corresponds to either Qor Z. For these 2 letters your program should print a message indicating that they...
JAVA CODE Beginner. please use if, else if or switch statements, but don't use arrays, please Write a program that reads a string from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a message explaining why it is not valid. The input date will have the format mm/dd/yyyy. A valid month value mm must be from 1 to 12...
Write the code in java. Just a simple code with no While
loop. If-else statement is permitted. Thanks.
Game rule: paper beats rock; rock beats scissor and scissor beats paper. Paper-0; rock-1; sissor 2 Computer generates random number 0-2 int computerGuess; computerGuess (int) (Math.random ()*3) You are asked to enter value 0-2 Use at least one switch statement DETERMINE WHO WINS OR TIE BECAUSE BOTH PICKED SAME VALUE PRINT-what computer picked, what you picked and who won "Computer picked rock,...
java program
QUESTION 2: 1. Write a do-while loop that asks the user to select a task from the following menu to continue: 1. Option 1 2. Option 2 3. Option 3 4. Option 4 5. Exit Read the selection from the keyboard then write the switch statement: For option 1, display the message "Do the option 1" For option 2, display the message "Do the option 2" For option 3, display the message "Do the option 3" For option...
JAVA Code: Complete the program that reads from a text file and counts the occurrence of each letter of the English alphabet. The given code already opens a specified text file and reads in the text one line at a time to a temporary String. Your task is to go through that String and count the occurrence of the letters and then print out the final tally of each letter (i.e., how many 'a's?, how many 'b's?, etc.) You can...
Java Write code for the problem: The user enters exactly 5 scores. Use a for loop to input the scores and count the number of scores that are greater or equal to 80. Print the result after all 5 scores have been entered.
use java and write in text
a. Rewrite the following code segment using if statements. Assume that grade has been declared as of type char. char grade= 'B';; switch (grade) { case 'A': System.out.println("Excellent"); break case 'B': System.out.println("Good"); default: System.out.println("you can do better”); } - b. write Java code that inputs an integer and prints each of its digit followed by ** e.gif the integer is 1234 then it should print 1**2**3**4 e.g. if the integer is 85 then it...
in java Use a for loop and nested if statements to determine if a number is even or prime Use the numbers 30 to 60 Hint: you may need to review what is a prime number Output: 30 . . . even 31 . . . prime number 32 . . . even 33 . . . 34 . . . even 35 . . . 36 . . . even 37 . . . prime number etc.
PLEASE SOLVE THESE QUESTIONS. USE JAVA FOR CODING.
Q.5.8 Write short Java code to display the following screen (no need to do it practically using a compiler, just basic coding to display the screen): Sample screenshot Input х ? Enter (1) to display the vowel count. Enter (2) to display the non vowel count. Enter (0) to exit. OK Cancel Q.5.9 Write a short Java code to display the following screen (no need to do it practically using a compiler,...
USE JAVA. Just a basic code. We these in Blue J
2) Write a while loop that lets the user enter a number. The number should be multiplied by 10 and the result stored in the variable product. The loop should iterate as long as product contains a value less than 100. 3) Write a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The user should be asked if...