Interactive program

Interactive program

hello friends.i need to write an interactive program using java in that when i output it it borrows me details that i should enter and at long last it outputs all those details together.Example a program that will calculate the grades of students in a class.this is are some of the details.Name of student,registration number, marks obtained per subject,grade per subject,total marks,general grade.and this is how it will go when you execute it.it will ask you to enter the name of the student,after that his/her registration number, marks per subject.then this program will calculate grades per subject and the final grade.lastly it will give all this details together.please contribute something

View Answers

November 16, 2010 at 1:23 PM

Hi Friend,

Try the following code:

import java.util.*;

public class StudentResult{
    String studentID;
    String name;
    double hindi;
    double maths;
    double science;
    double total;
    String grade;
public void setStudentID(String studentID){
    this.studentID=studentID;
}
public String getStudentID(){
    return studentID;
}
public void setName(String name){
this.name=name;
}
public String getName(){
    return name;
}
public void setHindi(double hindi){
this.hindi=hindi;
}
public double getHindi(){
    return hindi;
}
public void setMaths(double maths){
this.maths=maths;
}
public double getMaths(){
    return maths;
}
public void setScience(double science){
this.science=science;
}
public double getScience(){
    return science;
}
public void setTotal(double total){
this.total=total;
}
public double getTotal(){
    return total;
}
public void setGrade(String grade){
this.grade=grade;
}
public String getGrade(){
    return grade;
}
public static void main(String[]args){
    Scanner input=new Scanner(System.in);
    System.out.print("No of students in a class: ");
    int menu = input.nextInt();
    System.out.println();

StudentResult data[]=new StudentResult[menu];
for (int i=0; i<data.length; i++) {
    int j=i+1;
 System.out.println();
System.out.println("********Student "+j+"*********");
System.out.println("Enter Registration No:");
            String no=input.next();
            System.out.println("Enter Name: ");
            String n=input.next();
            System.out.println("Marks in Hindi:");
            double m1=input.nextDouble();
            System.out.println("Marks in Maths:");
            double m2=input.nextDouble();
            System.out.println("Marks in Science");
            double m3=input.nextDouble();
            double tmarks=m1+m2+m3;
            double tm=tmarks/3;
            data[i] = new StudentResult();
data[i].setStudentID(no);
data[i].setName(n);
data[i].setHindi(m1);
data[i].setMaths(m2);
data[i].setScience(m3);
data[i].setTotal(tmarks);

November 16, 2010 at 1:24 PM

continue.........

if(tm<40){
data[i].setGrade("Fail");
}
if(tm>40&&tm<60){
    data[i].setGrade("D");
}
if(tm>60&&tm<70){
    data[i].setGrade("C");
}
if(tm>70&&tm<90){
    data[i].setGrade("B");
}
if(tm>90){
    data[i].setGrade("A");
}
}
 System.out.println();
String g1="",g2="",g3="";
for(int i=0;i<menu;i++){
      StudentResult show = data[i];
      String ide=show.getStudentID();
      String nn=show.getName();
        double mar1=show.getHindi();
          double mar2=show.getMaths();
            double mar3=show.getScience();
                 double tot=show.getTotal();
                 String g = show.getGrade();
      System.out.println("Result of Student "+(i+1));
      System.out.print("Registration Number: "+ide+"\n");
      System.out.print("Student Name: "+nn+"\n");
      if(mar1<40){
    g1="Fail";
}
if(mar1>=40&&mar1<=60){
    g1="D";
}
if(mar1>60&&mar1<=70){
    g1="C";
}
if(mar1>70&&mar1<=90){
    g1="B";
}
if(mar1>90){
    g1="A";
}

 if(mar2<40){
    g2="Fail";
}
if(mar2>40&&mar2<60){
    g2="D";
}
if(mar2>60&&mar2<70){
    g2="C";
}
if(mar2>70&&mar2<90){
    g2="B";
}
if(mar2>90){
    g2="A";
}

 if(mar3<40){
    g3="Fail";
}
if(mar3>40&&mar3<60){
    g3="D";
}
if(mar3>60&&mar3<70){
    g3="C";
}
if(mar3>70&&mar3<90){
    g3="B";
}
if(mar3>90){
    g3="A";
}
      System.out.print("Marks in Hindi: "+mar1+"\n");
      System.out.print("Grade in Hindi: "+g1+"\n");
      System.out.print("Marks in Maths: "+mar2+"\n");
      System.out.print("Grade in Maths: "+g2+"\n");
      System.out.print("Marks in Science: "+mar3+"\n");
      System.out.print("Grade in Science: "+g3+"\n");
      System.out.print("Total Marks: "+tot+"/300\n");
      System.out.print("Final Grade: "+g+"\n");
      System.out.println();
      }
    }
}

Thanks









Related Tutorials/Questions & Answers:
Interactive program
Interactive program  hello friends.i need to write an interactive program using java in that when i output it it borrows me details that i should enter and at long last it outputs all those details together.Example a program
ModuleNotFoundError: No module named 'Interactive'
ModuleNotFoundError: No module named 'Interactive'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Interactive' How to remove the ModuleNotFoundError: No module named '
Advertisements
Interactive map
Interactive map  hi........ i require map to be zoom in and enlarge the area and show its detail. Can anyone tel me how can this be done using java swings .... plz help
Interactive Maps
Interactive Maps  Hi....................... How can u make maps interactive using java code. I mean if a map of some location is stored in database then when we retrieve it and display on java form then when a click
ModuleNotFoundError: No module named 'beam_interactive'
ModuleNotFoundError: No module named 'beam_interactive'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'beam_interactive' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'mapper-interactive'
ModuleNotFoundError: No module named 'mapper-interactive'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'mapper-interactive' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'mapper-interactive'
ModuleNotFoundError: No module named 'mapper-interactive'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'mapper-interactive' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'pytest-interactive'
ModuleNotFoundError: No module named 'pytest-interactive'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pytest-interactive' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'python-interactive'
ModuleNotFoundError: No module named 'python-interactive'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'python-interactive' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'beam_interactive'
ModuleNotFoundError: No module named 'beam_interactive'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'beam_interactive' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'discord-interactive'
ModuleNotFoundError: No module named 'discord-interactive'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'discord-interactive' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'django-interactive'
ModuleNotFoundError: No module named 'django-interactive'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'django-interactive' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'gbdx-interactive'
ModuleNotFoundError: No module named 'gbdx-interactive'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'gbdx-interactive' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'interactive-components'
ModuleNotFoundError: No module named 'interactive-components'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'interactive-components' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'interactive-input'
ModuleNotFoundError: No module named 'interactive-input'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'interactive-input' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'interactive-python'
ModuleNotFoundError: No module named 'interactive-python'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'interactive-python' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'interactive-shell'
ModuleNotFoundError: No module named 'interactive-shell'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'interactive-shell' How to remove the ModuleNotFoundError: No module
Interactive Maps ways
Interactive Maps ways  hi........ Is there any way to make interactive in project i mean how to do some event on maps to make them interactive..??????????/ can anyone tel me how to do that.......??????? using java swings plz
ModuleNotFoundError: No module named 'ansi-interactive-search'
ModuleNotFoundError: No module named 'ansi-interactive-search'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'ansi-interactive-search' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'ansi-interactive-search'
ModuleNotFoundError: No module named 'ansi-interactive-search'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'ansi-interactive-search' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'Custom-Interactive-Console'
ModuleNotFoundError: No module named 'Custom-Interactive-Console'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Custom-Interactive-Console' How to remove
ModuleNotFoundError: No module named 'iotile-analytics-interactive'
ModuleNotFoundError: No module named 'iotile-analytics-interactive'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'iotile-analytics-interactive' How to remove
ModuleNotFoundError: No module named 'opal-azure-cli-interactive'
ModuleNotFoundError: No module named 'opal-azure-cli-interactive'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'opal-azure-cli-interactive' How to remove
ModuleNotFoundError: No module named 'pandas-interactive-html'
ModuleNotFoundError: No module named 'pandas-interactive-html'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pandas-interactive-html' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'ansi-interactive-search'
ModuleNotFoundError: No module named 'ansi-interactive-search'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'ansi-interactive-search' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'azure-cli-interactive'
ModuleNotFoundError: No module named 'azure-cli-interactive'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'azure-cli-interactive' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'Custom-Interactive-Console'
ModuleNotFoundError: No module named 'Custom-Interactive-Console'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Custom-Interactive-Console' How to remove
ModuleNotFoundError: No module named 'dash-interactive-graphviz'
ModuleNotFoundError: No module named 'dash-interactive-graphviz'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'dash-interactive-graphviz' How to remove
ModuleNotFoundError: No module named 'interactive-judger-py'
ModuleNotFoundError: No module named 'interactive-judger-py'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'interactive-judger-py' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'iotile-analytics-interactive'
ModuleNotFoundError: No module named 'iotile-analytics-interactive'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'iotile-analytics-interactive' How to remove
Artifacts of com.forest-interactive
List of Artifacts of com.forest-interactive maven depenency
Interactive, Non-Interactive Gauge Example
Interactive, Non-Interactive Gauge Example   ... to draw the interactive and non-interactive gauge which is used to display... as:ADS_TO_REPLACE_1 Gauge(String label, boolean interactive, int maxValue, int
interactive learning machine learning
interactive learning machine learning  Hi, I am beginner in Data...: interactive learning machine learning Try to provide me good examples or tutorials links so that I can learn the topic "interactive learning machine
interactive machine learning examples
interactive machine learning examples  Hi, I am beginner in Data...: interactive machine learning examples Try to provide me good examples or tutorials links so that I can learn the topic "interactive machine learning
Version of com.forest-interactive>aseandcb dependency
machine learning interactive
machine learning interactive  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: machine learning interactive Try to provide me good examples or tutorials links so that I
ModuleNotFoundError: No module named 'Speech_based_Interactive_Location_Guide'
ModuleNotFoundError: No module named 'Speech_based_Interactive_Location_Guide'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'Speech_based_Interactive_Location_Guide' How
program
program  any program of hotel or school management
program
program  write a javascript program to create a application form with validation
program
program  program of jdbc using ms access for creating table
program
program  write a html program in show table and this word in box
program
program  write a program different between to dates in terms of days in java
program
program  WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program   Write a program to find the difference between sum of the squares and the square of the sums of n numbers
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program
program   An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the program calculateTotalProfit that consumes
program
program  write a java program to input a no. and print wheather the no. is a special no or not. (special no. are those no whose factorial of the sum of digit of the no is same as the original
program
program  Develop the program calculateCylinderArea, which accepts radius of the cylinder's base disk and its height and computes surface area of the cylinder
program
program  explanation of program on extending thread class   Hi Friend, Please go through the following link:ADS_TO_REPLACE_1 Java Threads Thanks

Ads