Computer Science, asked by mohammadaansari07, 8 months ago

Write a program in Java to create a class Student with following variables. [6]
• Name : String
• Class : Integer
• Roll-no : Integer
• Bus : char
• Mark1(out of 100) : double
• Mark2(out of 100) : double
• Mark3(out of 100) : double
Accept the following details for a student using Input Stream reader. Find the average marks
and display the average along with the name of the student in the following format.
*********
Result
Name :
Average:
***********
This question is from Java Bluej.
You CANNOT use scanner class only inputstreamreader.

Answers

Answered by priyanshumishramps21
2

Answer:

//program to get student details

import java.util.Scanner;

public class GetStudentDetails

{

public static void main(String args[])

{

String name;

int roll, math, phy, eng;

Scanner SC=new Scanner(System.in);

System.out.print("Enter Name: ");

name=SC.nextLine();

System.out.print("Enter Roll Number: ");

roll=SC.nextInt();

System.out.print("Enter marks in Maths, Physics and English: ");

math=SC.nextInt();

phy=SC.nextInt();

eng=SC.nextInt();

int total=math+eng+phy;

float perc=(float)total/300*100;

System.out.println("Roll Number:" + roll +"\tName: "+name);

System.out.println("Marks (Maths, Physics, English): " +math+","+phy+","+eng);

System.out.println("Total: "+total +"\tPercentage: "+perc);

}

}

Similar questions