# how to do these program letters with values

• 02-20-2013, 01:49 PM
w0ooop
how to do these program letters with values
create a program that will perform the following operation
1. accept 1-5 letters.
2. each letter corresponds to a number.
3. generates the sum of the numbers selected.
4.displays the average of the numbers selected.

values of letter A=20 B=4 C=7 D=9 E=10 F=15 O=6 U=12 S=12
.. joption o scanner only can be use
• 02-20-2013, 01:54 PM
PhHein
Re: how to do these program letters with values
What have you done so far? Nobody will do your homework for you. Start yourself and ask specific questions when you get stuck.
• 02-20-2013, 01:58 PM
w0ooop
Re: how to do these program letters with values
nope i know..im stuck with how should the operation should be..... im having trouble with question 3 and 4 how should i do the mathematical equation 1 by 1???
• 02-20-2013, 01:59 PM
w0ooop
Re: how to do these program letters with values
i use int to specify the equivalent of a letter like int A = 20; or i should use char??
• 02-20-2013, 02:01 PM
w0ooop
Re: how to do these program letters with values
should i do that like q = a+ b; q = a + c ?
• 02-20-2013, 02:11 PM
w0ooop
Re: how to do these program letters with values
public static void main(String[] args) {
int A = 20,B = 4,C=7,D = 9, E = 10, F = 15, O = 6, U = 12, S = 12;
int q;

Scanner scan = new Scanner(System.in);

System.out.println("Choose 2-5 letter from A,B,C,D,E,F,O,U,S");
q= scan.nextInt();

q = A + B;
q = A + C;
System.out.println("the sum of the enter letter is:"+q);

should i continue this kind of equation??
• 02-20-2013, 02:26 PM
PhHein
Re: how to do these program letters with values
scan.nextInt() won't help you here, as the user enters a String. Read the String and make sure it has the correct length and contains only valid characters. If it doesn't match the requirements prompt the user to reenter.
When you're done with that part you can start thinking about converting the input. One after the other, always break down the task into small bits.
• 02-20-2013, 02:41 PM
w0ooop
Re: how to do these program letters with values
what should i put q = ?? ishould use loop??
• 02-20-2013, 02:46 PM
PhHein
Re: how to do these program letters with values
Forget about ints! Just make sure you can read and verify the user input. Ints come later.
• 02-20-2013, 03:14 PM
w0ooop
Re: how to do these program letters with values
how should i do to recognize the letter i type?
• 02-20-2013, 03:18 PM
w0ooop
Re: how to do these program letters with values
how should the letter could be recognize?? public static void main(String[] args) {
int A = 20,B = 4,C=7,D = 9, E = 10, F = 15, O = 6, U = 12, S = 12;
int sum,letters=0,q,w;

Scanner scan = new Scanner(System.in);

System.out.println("Choose 2-5 letter from A,B,C,D,E,F,O,U,S");
q = scan.nextInt () ;
System.out.println("Choose 2-5 letter from A,B,C,D,E,F,O,U,S");
w = scan.nextInt () ;
if (letters<2);

sum = q + w;
System.out.println("the sum of the letters is:"+sum);
• 02-20-2013, 03:22 PM
PhHein
Re: how to do these program letters with values
Man, keep it simple! You cannot ever read any input from the user as is. One step after the other. Just read any input and print it to the console. After that you can think about validation.
• 02-20-2013, 03:49 PM
w0ooop
Re: how to do these program letters with values
i couldnt understand what should ill do to recognize the value of the letter??
• 02-20-2013, 04:03 PM
Tolls
Re: how to do these program letters with values
Listen to what PhHein is saying.
You are jumping ahead of yourself.

Software development is about breaking the task in front of you down to the smallest steps.
It is being suggested to you to start with the simple step of reading input from the console into a String variable and output it back to the screen to check it is doing it correctly.

Once you have that code you can then start to look at turning it into numbers.
• 02-20-2013, 04:07 PM
w0ooop
Re: how to do these program letters with values
so ishould have string sorry im just new to programming... im not that knowledgeble about it..
• 02-20-2013, 04:26 PM
PhHein
Re: how to do these program letters with values
Yes, use a String as input.
• 02-20-2013, 04:26 PM
w0ooop
Re: how to do these program letters with values
i dont know how to make it I surrender shit... time to rest hope i had some help how should do it right but thanks to all of you... i hope i can improve on it