0

hello, i have a code below and i dont know how to make a string input for me to input hte name of the student...kindly check it out...

import java.io.*;
public class io
{
public static InputStreamReader reader = new InputStreamReader(System.in);	
public static BufferedReader input= new BufferedReader(reader);
public static void main (String[]args)throws Exception {
	
double grade1,grade2,grade3,grade4,average;
String name;
		
System.out.println("Enter Student's Name: ");
		
// HOW DO I INTEGRATE THE CODE TO INPUT STUDENTS NAME?
		
System.out.println("Enter First Grading: ");
grade1=Double.parseDouble(input.readLine());
System.out.println("Enter Second Grading: ");
grade2=Double.parseDouble(input.readLine());
System.out.println("Enter Third Grading: ");
grade3=Double.parseDouble(input.readLine());
System.out.println("Enter Fourth Grading: ");
grade4=Double.parseDouble(input.readLine());
average=(grade1 + grade2 + grade3 + grade4)/4;
System.out.println("The avegrage is: "+ average);

}
	
}
2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by lloydsbackyard
0

hi lloydsbackyard,
it is just simple... the readline method will return the string

there you have to give
name=input.readLine();

without the parsing to the double...

0

hi lloydsbackyard,
it is just simple... the readline method will return the string

there you have to give
name=input.readLine();

without the parsing to the double...

THANK YOU VERY MUCH! ITS NOW RUNNING!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.