![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Oct 2004
Posts: 31
Rep Power: 0
![]() |
help needed
i am having a diifficulty in solving this problem.
the user enter student name,and it ask for 5 grades.The grades should be only A,B,C,D,F..i did it but cannot get the answer..becoz it does not validate the characters ..i will post the code.. import javax.swing.*; import java.io.*; class CalculateGrade { public static void main(String args[])throws IOException { char grade=' '; System.out.println("Grade marks"+"\t\t"+"Points"+"\n"); System.out.println("================================="); System.out.println("A"+"\t\t\t"+"4"+"\t\t"+"\n"); System.out.println("B"+"\t\t\t"+"3"+"\t\t"+"\n"); System.out.println("C"+"\t\t\t"+"2"+"\t\t"+"\n"); System.out.println("D"+"\t\t\t"+"1"+"\t\t"+"\n"); System.out.println("E"+"\t\t\t"+"0"+"\t\t"+"\n"); for(int a=1;a<=10;a++) { System.out.println(); System.out.println("STUDENT#"+a); System.out.println("========="); String name=JOptionPane.showInputDialog("enter student#"+a); char response=userGrade(grade); } } public static char userGrade(char chr)throws IOException { char ans=' '; char response=' '; for(int a=1;a<=5;a++) { System.out.println(); System.out.println("Grade#"+a); System.out.println("=========="); System.in.read(); System.in.read(); ans=(char)System.in.read(); } return ans; } } |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|