tooba

Programming
Tutor: None Selected Time limit: 3 Days

write a program that inputs an alphabet in upper case and prints the corresponding telephone digit.
In case user enter any letter other than A to Z program should display invalid input
and terminate. In order to stop the program user should enter #

Aug 28th, 2013
public class A {

public static void main(String[] args) {

try
{
int c= System.in.read();
char v='#';
do
{
if((char)c==v)
System.exit(1);
else
if(c<65&&c>90)
System.out.print("Invalid input,enter alphabets in caps only");
else
if(c<=65&&c<=90)
{
if(c>=65&&c<=67)
System.out.print("2");
else
if(c>=68&&c<=70)
System.out.print("3");
else
if(c>=71&&c<=73)
System.out.print("4");
else
if(c>=74&&c<=76)
System.out.print("5");
else
if(c>=77&&c<=79)
System.out.print("6");
else
if(c>=80&&c<=83)
System.out.print("7");
else
if(c>=84&&c<=86)
System.out.print("8");
else
if(c>=87&&c<=90)
System.out.print("9");
}


}while(c!='#');
}
catch(Exception e)
{
System.out.println(e);
}
}
}



use this code in netbeans 7.3 u most probably will find no error and will get the output. The logic is exactly tru....
Aug 29th, 2013

Studypool's Notebank makes it easy to buy and sell old notes, study guides, reviews, etc.
Click to visit
The Notebank
...
Aug 28th, 2013
...
Aug 28th, 2013
May 30th, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer