Write a Java program which print roll no name and class on screen
Answers
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);
}
}
Answer:
import java.util.*;
class MyProfile
{
public void main()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter your name");
String n=sc.next();
System.out.println("Enter your class");
int c=sc.nextInt();
System.out.println("Enter your roll number");
int rn=sc.nextInt();
System.out.println("Name :"+n);
System.out.println("Class "+c);
System.out.println("Roll number"+rn);
}
}
MARK IT BRAINLIEST, IF YOU GET HELP FROM THIS