Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Interactive program

Have Programming Question? Ask it here!
 
 
 


Timothy Ouko Omare
Interactive program
2 Answer(s)      3 years and 8 months ago
Posted in : Java Beginners


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


Advertisement
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
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
Advertisements
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
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
Interactive, Non-Interactive Gauge Example
Interactive, Non-Interactive Gauge Example   ... to draw the interactive and non-interactive gauge which is used to display... as: Gauge(String label, boolean interactive, int maxValue, int initialValue
JSP - Abobe Interactive Forms - JSP-Servlet
JSP - Abobe Interactive Forms  Dear Gurus, Hi! I have a problem... to fill a form. I have used Abobe Interactive Form for that and I am using Apache... running your program at that time automatically write XML coding by j2ee
INTERACTIVE TRANSMISSION OF JPEG2000 IMAGES USING WEB - JSP-Servlet
INTERACTIVE TRANSMISSION OF JPEG2000 IMAGES USING WEB  Hello Friend, I want INTERACTIVE TRANSMISSION OF JPEG2000 IMAGES USING WEB using jsp .. Can you help me
program
program  any program of hotel or school management
Fetching data from excel file on other website and display in interactive graph form
Fetching data from excel file on other website and display in interactive graph form  Hello, I am making a website using HTML and CSS, I am done with the layout, I have to generate ineractive graphs like stock market's, Can you
program
program  write a program different between to dates in terms of days in java
program
program  write a html program in show table and this word in box
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  WAP a java program to form 1/2+3/4+5/6+7/8 series
program
program  develop a servlet to insert the data in the database from our program in the table stored in the database
program
program  write a program reversee a string. input-hi this is roseindia output-roseindia is this hi
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   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: Java Threads Thanks
Program
Program  a program to create two classes Commercial and Domestic. Override the method calculatebill() of Commercial class(Rs.8 per unit) into Domestic class(Rs 6 per unit) to compute electricity bill for both classes
Program
Program  a program to prove that default constructor of super class is available to subclass by default. Define a parameterize constructor for super class to store name = ‚??Tommy‚?? age=‚??23‚?? and call this constructor
program
program  how to improve programming skills plss tell some tips..i am understanding concepts but unable to write program so,pls give some guideness plsss
program
program  Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean
program
program  no i want a program that shows how merge sort algorithm works in graphical representations like numbers are taken in circles and computation... in rectangles or circles wat ever it may be. the theme of program is to show algorithm
program
program  i want a progra in java to print a sentence in alphabetic order, taking the input from the user.the program should writen without using the array for example : if input= this is a cat then output sould = a cat
program
program  Write a JSP Program, which displays a web page containing the name of the Courses, Courses being offered currently, number of students enrolled in each course, new courses to be offered, eligibility criteria for taking
program
program  . Develop a program that accepts an initial amount of money (called the principal), a simple annual interest rate, and a number of months will compute the balance at the end of that time. Assume that no additional
program
program  Write a program to print details of a week for a particular day using array of objects Integer and String. OUTPUT: First Day of Week is Monday Second Day of Week is Tuesday Third Day of Week is Wednesday Forth Day
program
program  Write a JSP Program, which displays a web page containing two web links one for your profiling and other for the schedule of theory of practical classes of your Batch. When one click on link for getting your profile
program
program  Utopias tax accountants always use programs that compute income taxes even though the tax rate is a solid, never-changing 15%. Define the program calculateTax which determines the tax on the gross pay. Define
program calculateCylinderVolume
program calculateCylinderVolume  program calculateCylinderVolume
java program for
java program for   java program for printing documents,images and cards
program in java
program in java  a program to develop a client, server application to satisfy the requests from multiple clients
program of c
program of c  write a program in c to display a to z without using printf or scanf statements or header files
string program
string program  write a program to print the pattern p r o program r a m
program in java
program in java  a program to develop a client, server application to satisfy the requests from multiple clients
a Java program
a Java program    Write a Java program to print even numbers from 2 to 1024? Write a Java program to print ? My Name is Mirza? 100 times? Write a Java program to print Fibonacci Series? Write a Java program to reverse a number
Jsp program
Jsp program  A sample program of jsp using dml quaries
java program
java program  write a program to print 1234 567 89 10
Java Program
Java Program  A Java Program that print the data on the printer but buttons not to be printed
program for factorial
program for factorial  how to set size of buttons on frame
program for factorial
program for factorial  how to set size of buttons on frame
program coding
program coding  how to rearrange the array a[1]. . a[n] even elements and odd elements? please give the example coding program
program code
program code  I want a program that accepts a word from TextField and check with multiple .csv file and displays the snippets from csv file into TextArea. Please help me
java program
java program  Write a program to demonstrate the concept of various possible exceptions arising in a Java Program and the ways to handle them.   For more information, visit the following link: Exception Handling
program binary
program binary  Hi I want to write a program in pascal that ask a user to input a decimal number and then return its binary equivalent in the minimum number of bits required to repesent the number. In pascal language please
program coding
program coding  write a c program to rearrange the array a[1]. . .a[n] in such a way that all even elements precede all odd elements (not changing the order inside each of the two groups
ava program
ava program   Explain the process of deleating and renaming a file in a Java program with the help of suitable example.   Please visit the following links: Renaming File Delete File
 

 

 

DMCA.com