# Thread: how to do these program letters with values

1. Member
Join Date
Feb 2013
Posts
11
Rep Power
0

## 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

2. ## 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.

3. Member
Join Date
Feb 2013
Posts
11
Rep Power
0

## 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???

4. Member
Join Date
Feb 2013
Posts
11
Rep Power
0

## 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??

5. Member
Join Date
Feb 2013
Posts
11
Rep Power
0

## Re: how to do these program letters with values

should i do that like q = a+ b; q = a + c ?

6. Member
Join Date
Feb 2013
Posts
11
Rep Power
0

## 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??

7. ## 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.

8. Member
Join Date
Feb 2013
Posts
11
Rep Power
0

## Re: how to do these program letters with values

what should i put q = ?? ishould use loop??

9. ## 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.

10. Member
Join Date
Feb 2013
Posts
11
Rep Power
0

## Re: how to do these program letters with values

how should i do to recognize the letter i type?

11. Member
Join Date
Feb 2013
Posts
11
Rep Power
0

## 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);

12. ## 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.

13. Member
Join Date
Feb 2013
Posts
11
Rep Power
0

## Re: how to do these program letters with values

i couldnt understand what should ill do to recognize the value of the letter??

14. Moderator
Join Date
Apr 2009
Posts
11,302
Rep Power
18

## 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.

15. Member
Join Date
Feb 2013
Posts
11
Rep Power
0

## 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..

16. ## Re: how to do these program letters with values

Yes, use a String as input.

17. Member
Join Date
Feb 2013
Posts
11
Rep Power
0

## 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

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•