/*
* The java program that prompts user to enter the letter
* from the console and then using switch case to find the digit
corresponding to
* on the telephone and then display the digit corresponding to the
letter
* and otherwise print an error message indicating that there
* is not digit corresponding to letter.
* */
//Exercise_2.java
import java.util.Scanner;
public class Exercise_2
{
public static void main(String[] args)
{
//Create a Scanner class object to
read input from console
Scanner kboard=new
Scanner(System.in);
char letter;
int digit = 0;
//read letter from console
System.out.print("Enter a single
letter and you will get the corresponding digit on the telephone:
");
letter=kboard.nextLine().charAt(0);
/*Switch case to match the case
label for letter*/
switch(letter)
{
case 'Q':
case 'Z':
//set digit to
-1 for Q and Z letters
digit=-1;
break;
case 'A':
case 'B':
case 'C':
digit=2;
break;
case 'D':
case 'E':
case 'F':
digit=3;
break;
case 'G':
case 'H':
case 'I':
digit=4;
break;
case 'J':
case 'K':
case 'L':
digit=5;
break;
case 'M':
case 'N':
case 'O':
digit=6;
break;
case 'P':
case 'R':
case 'S':
digit=7;
break;
case 'T':
case 'U':
case 'V':
digit=8;
break;
case 'W':
case 'X':
case 'Y':
digit=9;
break;
}
/*Check if digit is -1 the print
the error message*/
if(digit==-1)
System.out.println("There is no digit on the telephone that
corresponds to "+letter);
else
//Otherwise
print the letter corresponding to the digit
System.out.println("The digit "+digit+" corresponds to the letter
"+letter+" on the telephone.");
}
}
----------------------------------------------Sample
Output------------------------------------------------------
Run#1
Run#2
hello. i need help with number 2 ONLY 1. Use if statements to write a Java...
Write a C++ 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 4 = GHI 6 = MNO 8 = TUV3 = DEF 5 = JKL 7 = PRS 9 = WXYNo digits correspond to either Q or Z. For these two letters, your program should print a messageindicating that they are not used on a telephone. If a letter in lower...
Please I need help with this c++ code. please show all steps , write comments and show sample runs. Thank you. 1. The Federal Bureau of Investigation (FBI) has recently changed its Universal Control Numbers (UCN) for identifying individuals who are in the FBI's fingerprint database to an eight-digit base 27 value with a ninth check digit. The digits used are: 0123456789ACDE FHJKLMNPRTVWX Some letters are not used because of possible confusion with other digits: B->8, G->C, I- >1, 0->0,...
in java plz amaining Time: 1 hour, 49 minutes, 15 seconds. Jestion Completion Status: Write a program that asks the user for an input file name, open, read ar number of students is not known. For each student there is a name and and display a letter grade for each student and the average test score fc • openFile: This method open and test the file, if file is not found and exit. Otherwise, return the opened file to the...
Input hello, I need help completing my assignment for java,Use the following test data for input and fill in missing code, and please screenshot output. 1, John Adam, 3, 93, 91, 100, Letter 2, Raymond Woo, 3, 65, 68, 63, Letter 3, Rick Smith, 3, 50, 58, 53, Letter 4, Ray Bartlett, 3, 62, 64, 69, Letter 5, Mary Russell, 3, 93, 90, 98, Letter 6, Andy Wong, 3, 89,88,84, Letter 7, Jay Russell, 3, 71,73,78, Letter 8, Jimmie Wong,...
I need help programming this program in C. 1.) Write a program that reads a message, then checks whether it's a palindrome (the letters in the message are the same from left to right as from right to left), example is shown below: Enter a message: He lived as a devil, eh? Palindrome Enter a message: Madam, I am Adam. Not a Palindrome 2.) Ignore all characters that aren't letters. Use integer variables to keep track of positions in the...
Given java code is below, please use it! import java.util.Scanner; public class LA2a { /** * Number of digits in a valid value sequence */ public static final int SEQ_DIGITS = 10; /** * Error for an invalid sequence * (not correct number of characters * or not made only of digits) */ public static final String ERR_SEQ = "Invalid sequence"; /** * Error for...
I want to change this code and need help. I want the code to not use parallel arrays, but instead use one array of struct containing the data elements, String for first name, String for last name,Array of integers for five (5) test scores, Character for grade. If you have any idea help would be great. #include #include #include #include using namespace std; const int NUMBER_OF_ROWS = 10; //number of students const int NUMBER_OF_COLUMNS = 5; //number of scores void...
Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...
For the following task, I have written code in C and need help in determining the cause(s) of a segmentation fault which occurs when run. **It prints the message on line 47 "printf("Reading the input file and writing data to output file simultaneously..."); then results in a segmentation fault (core dumped) I am using mobaXterm v11.0 (GNU nano 2.0.9) CSV (comma-separated values) is a popular file format to store tabular kind of data. Each record is in a separate line...
Hey guys I need help with this assignment. However it contains 7 sub-problems to solve but I figured only 4 of them can be solved in one post so I posted the other on another question so please check them out as well :) Here is the questions in this assignment: Note: Two helper functions Some of the testing codes for the functions in this assignment makes use of the print_dict in_key_order (a dict) function which prints dictionary keyvalue pairs...