please help !need rush. i dont know how the computations should be done.. :(
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
either or joption o scanner ang gagamitin
just a newbie with Data structure and algo please help to solve this .. ...
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?? or how should the computation should be done
can i ask how can a letter with value can be recognize in a program??
can i ask how can a letter with value can be recognize in a program??
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
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);
if (letters<2);
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 () ;
sum = q + w;
System.out.println("the sum of the letters is:"+sum);
Re: can i ask how can a letter with value can be recognize in a program??
Code :
int A = 20,B = 4,C=7,D = 9, E = 10, F = 15, O = 6, U = 12, S = 12;
The names of variables are not useful when looking that user input.
There are several ways to associate a letter input by a user with a value:
One is to use a switch statement
Another is to use a String and an array of the values with the letter's position in the String corresponding to the index into the array.
Another would be a Map with the letter being the key and the value being the numeric value.
what wrong?? the value of the letter couldn't recognize
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);
the value of the letter couldn't recognize
Re: can i ask how can a letter with value can be recognize in a program??
Quote:
the value of the letter couldn't recognize
Please explain the problem.
The code uses the wrong Scanner method to read a letter. nextInt() is for reading numbers.