convert to GUI

convert to GUI

import java.util.Scanner;

public class Exam
{
public static void main (String args[])
{

int numberStudent, mark, markAplus = 0, markA = 0, markBplus = 0, markB = 0, markBminus = 0, i;
int markCplus = 0, markC = 0, markCminus = 0, markDplus = 0, markD = 0, markE = 0;

Scanner input = new Scanner(System.in);
System.out.print("Please enter number of students in class: ");
numberStudent = input.nextInt();

for (i= 0;i<numberStudent;i++)
{

System.out.print("Please enter students marks: ");
mark = input.nextInt();


if (mark>=85 && mark <= 100)
{
System.out.println("\tGrade A+");
markAplus++; 


}
else if (mark>=80 && mark <= 84)
{
System.out.println("\tGrade A");
markA++;


}
else if (mark>=75 && mark <= 79)
{
System.out.println("\tGrade B+");
markBplus++;

}
else if (mark>=70 && mark <= 74)
{
System.out.println("\tGrade B");
markB++;

}
else if (mark>=65 && mark <= 69)
{
System.out.println("\tGrade B-");
markBminus++;


}
else if (mark>=60 && mark <= 64)
{
System.out.println("\tGrade C+");
markCplus++;


}
else if (mark>=55 && mark <= 59)
{
System.out.println("\tGrade C");
markC++;

}
else if (mark>=50 && mark <= 54)
{
System.out.println("\tGrade C-");
markCminus++;

}
else if (mark>=45 && mark <= 49)
{
System.out.println("\tGrade D+");
markDplus++;

}
else if (mark>=40 && mark <= 44)
{
System.out.println("\tGrade D");
markD++;

}
else
{
System.out.println("\tGrade E");
markE++;

}


}
System.out.println("\tGrade A+: "+markAplus); 
System.out.println("\tGrade A: "+markA);
System.out.println("\tGrade B+: "+markBplus);
System.out.println("\tGrade B: "+markB);
System.out.println("\tGrade B-: "+markBminus);
System.out.println("\tGrade C+: "+markCplus);
System.out.println("\tGrade C: "+markC);
System.out.println("\tGrade C-: "+markCminus);
System.out.println("\tGrade D+: "+markDplus);
System.out.println("\tGrade D: "+markD);
System.out.println("\tGrade E: "+markE);

} 
}
View Answers

November 14, 2011 at 3:50 PM

import java.awt.*; 
import javax.swing.*;
import java.awt.event.*;
public class Exam{ 
    double totalMarks;
    String grade;

public void setTotalMarks(double totalMarks) {
    this.totalMarks = totalMarks;
    }

public double getTotalMarks() {
    return totalMarks;
 }

public void setGrade(String grade) {
    this.grade = grade;
    }

public String getGrade(){
    return grade;
}

public static void main(String[] args) {
    JLabel lab=new JLabel("Enter number of students in class: ");
    final JTextField text=new JTextField(20);

    JButton b=new JButton("Find");
    lab.setBounds(10,10,150,20);
    text.setBounds(180,10,100,20);
    b.setBounds(180,40,100,20);

    JFrame f=new JFrame();
    f.setLayout(null);
    f.add(lab);
    f.add(text);
    f.add(b);
    f.setSize(300,100);
    f.setVisible(true);
    b.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e){

    int num = Integer.parseInt(text.getText());
    Exam data[] = new Exam[num];
    for(int a = 0; a < data.length; a++) {
       String input=JOptionPane.showInputDialog(null,"Please insert student marks: ");

        double marks = Double.parseDouble(input);
        while(marks>100||marks<0){
        String  st=JOptionPane.showInputDialog(null,"Invalid marks! Marks should be in between 0 to 100!");
            marks=Double.parseDouble(st);
        }
        data[a] = new Exam();
        data[a].setTotalMarks(marks);

        if(marks < 40){
            data[a].setGrade("E");
        }
        if(marks >= 40 && marks <= 44) {
            data[a].setGrade("D");
        }
        if (marks >= 45 && marks <= 49) {
            data[a].setGrade("D+");
        }
        if (marks >= 50 && marks <= 54) {
            data[a].setGrade("C-");
        }
        if (marks >= 55 && marks <= 59) {
            data[a].setGrade("C");
        }
        if (marks >= 60 && marks <= 64) {
            data[a].setGrade("C+");
        }
        if (marks >= 65 && marks <= 69) {
            data[a].setGrade("B-");
        }
        if (marks >= 70 && marks <= 74) {
            data[a].setGrade("B");
        }
        if (marks >= 75 && marks <= 79) {
            data[a].setGrade("B+");
        }
        if (marks >= 80 && marks <= 84) {
            data[a].setGrade("A");
        }
        if (marks >= 85 && marks <= 100) {
            data[a].setGrade("A+");
        }
        }

November 14, 2011 at 3:50 PM

continue..

int markAplus = 0, markA = 0, markBplus = 0, markB = 0, markBminus = 0;
int markCplus = 0, markC = 0, markCminus = 0, markDplus = 0, markD = 0, markE = 0;

        for (int i = 0; i < num; i++) {
            Exam show = data[i];
            String g = show.getGrade();
            if (g.equals("A+")) {
                markAplus++;
            }
            if (g.equals("A")) {
                markA++;
            }
            if (g.equals("B+")) {
                markBplus++;
            }
            if (g.equals("B")) {
                markB++;
            }
            if (g.equals("B-")){
                markBminus++;
            }
            if (g.equals("C+")){
                markCplus++;
            }
            if (g.equals("C")){
                markC++;
            }
            if (g.equals("C-")){
                markCminus++;
            }
            if (g.equals("D+")){
                markDplus++;
            }
            if (g.equals("D")){
                markD++;
            }
            if (g.equals("E")){
               markE++;
            }

        }
        JOptionPane.showMessageDialog(null,"Number of student getting A+: "+markAplus);
        JOptionPane.showMessageDialog(null,"Number of student getting A: "+markA);
        JOptionPane.showMessageDialog(null,"Number of student getting B+: "+markBplus);
        JOptionPane.showMessageDialog(null,"Number of student getting B: "+markB);
        JOptionPane.showMessageDialog(null,"Number of student getting B-:"+markBminus);
        JOptionPane.showMessageDialog(null,"Number of student getting C+: "+markCplus);
        JOptionPane.showMessageDialog(null,"Number of student getting C: "+markC);
        JOptionPane.showMessageDialog(null,"Number of student getting C-: "+markCminus);
        JOptionPane.showMessageDialog(null,"Number of student getting D+: "+markDplus);
        JOptionPane.showMessageDialog(null,"Number of student getting D: "+markD);
        JOptionPane.showMessageDialog(null,"Number of student getting E: "+ markE);


                }
        });
    }
}









Related Tutorials/Questions & Answers:
convert to GUI
convert to GUI  import java.util.Scanner; public class Exam { public static void main (String args[]) { int numberStudent, mark, markAplus = 0, markA = 0, markBplus = 0, markB = 0, markBminus = 0, i; int markCplus = 0, markC
Convert the code to GUI
How to Convert the code to GUI   How to convert a code into GUI
Advertisements
Convert the code to GUI
Java Code to GUI   can any one convert My code to GUI code
Convert the code to GUI
Convert the code   How to convert a code to GUI look alike
Convert the code to GUI
Is it possible to convert a code into GUI  Is it possible to convert a code into GUI
Convert the code to GUI
GUI code  GUI code
Convert the code to GUI
GUI Application example  GUI Application example
Convert the code to GUI
GUI Example  GUI Example code to learn
Convert the code to GUI
Java GUI Class Example  Java GUI Class Example
Convert the code to GUI
GUI Java JSP application  GUI Java JSP application
Convert the code to GUI
GUI Application Development   GUI Application Development
Convert the code to GUI
Java and GUI application Example  Java and GUI application Example
Convert the code to GUI
Write a GUI Application  best way to write a GUI based application
Convert the code to GUI
How to create GUI application in Java   How to create GUI application in Java
Convert the code to GUI ??
Convert the code to GUI ??  hi >> can anyone help me to conver this code to GUI ?? /** * @(#)RegistorClass.java * *. * @author * @version 1.00 2011/12/16 */ import java.util.Scanner; public class RegistorClass
Convert the code to GUI
Convert the code to GUI   can any one convert My code to GUI code import java.util.Scanner; public class RegistorClass { private int accumulator; private int instructionCounter; private int instructionRegister
Convert the code to GUI
GUI example for beginners  GUI example for beginners  sory ,, I will posted my code again import java.util.Scanner; public class RegistorClass { private int accumulator; private int instructionCounter; private
HOW TO CONVERT THIS CODE INTO GUI
HOW TO CONVERT THIS CODE INTO GUI   System.out.println("\n\t UGANDA CHRISTIAN UNIVERSITY\n"); System.out.println("\n\tFACULTY OF SCIENCE AND TECHNOLOGY\n"); System.out.println("\n BACHELOR OF SCIENCE IN COMPUTER
convert this code to GUI
convert this code to GUI  hello.. this is my code.. import java.util.Scanner; public class StudentGrade { double totalMarks; String grade; public void setTotalMarks(double totalMarks) { this.totalMarks
convert this code to GUI
convert this code to GUI  hello.. this is my code.. import java.util.Scanner; public class StudentGrade { double totalMarks; String grade; public void setTotalMarks(double totalMarks) { this.totalMarks
convert this code to GUI
convert this code to GUI  hello.. this is my code.. import java.util.Scanner; public class StudentGrade { double totalMarks; String grade; public void setTotalMarks(double totalMarks) { this.totalMarks
convert this code to GUI
convert this code to GUI  import java.util.Scanner; public class StudentGrade { double totalMarks; String grade; public void setTotalMarks(double totalMarks) { this.totalMarks = totalMarks; //"this" keyword
convert this code to GUI
convert this code to GUI  import java.util.Scanner; public class StudentGrade { double totalMarks; String grade; public void setTotalMarks(double totalMarks) { this.totalMarks = totalMarks; //"this" keyword
convert this code to GUI
convert this code to GUI  import java.util.Scanner; public class StudentGrade { double totalMarks; String grade; public void setTotalMarks(double totalMarks) { this.totalMarks = totalMarks; //"this" keyword
convert this code to GUI
convert this code to GUI  import java.util.Scanner; public class StudentGrade { double totalMarks; String grade; public void setTotalMarks(double totalMarks) { this.totalMarks = totalMarks; //"this" keyword
convert this code to GUI
convert this code to GUI  import java.util.Scanner; public class StudentGrade { double totalMarks; String grade; public void setTotalMarks(double totalMarks) { this.totalMarks = totalMarks; //"this" keyword
convert this code to GUI
convert this code to GUI  import java.util.Scanner; public class StudentGrade { double totalMarks; String grade; public void setTotalMarks(double totalMarks) { this.totalMarks = totalMarks; //"this" keyword
convert this code to GUI
convert this code to GUI  import java.util.Scanner; public class StudentGrade { double totalMarks; String grade; public void setTotalMarks(double totalMarks) { this.totalMarks = totalMarks; //"this" keyword
convert this code to GUI
convert this code to GUI  import java.util.*; class Author{ public String name; public BookList<Book>books=new BookList<Book>(); public Author(){ } public boolean equals(Object node){ return name.equals
convert this code to GUI
convert this code to GUI  import java.util.*; class Author{ public String name; public BookList<Book>books=new BookList<Book>(); public Author(){ } public boolean equals(Object node){ return name.equals
Convert this code to GUI - Java Beginners
); } }  hi friend, We have convert your code into GUI...Convert this code to GUI  I have written this.i need to convert the following code to GUI:- import java.awt.*; import java.applet.*; import
How to convert this Java code into GUI?
How to convert this Java code into GUI?   import java.util.Scanner; public class StudentMarks { double totalMarks; String grade; public void setTotalMarks(double totalMarks) { this.totalMarks = totalMarks
GUI convert to celsius program - Java Beginners
GUI convert to celsius program  how to write java GUI program to convert Fahrenheit to Celsius that need user to input value of Fahrenheit then click button convert and value of Celsius will display as a output.   Hi
GUI and how to convert a distance - Java Beginners
GUI and how to convert a distance  i need help.. how to create a GUI application that can be is used to convert a distance unit in miles into its... JLabel("In Inches"); l5=new JLabel("In CM"); b=new JButton("Convert
"Urgent" convert this code to GUI - Swing AWT
"Urgent" convert this code to GUI   please convert for me this code to GUI THE CODES ARE BELOW, CLASS ATMCaseStudy is the driver class that runs all the other classes. its very urgent. //CLASS CashDispenser public class
please convert for me this code to GUI - Swing AWT
please convert for me this code to GUI    THE CODES ARE BELOW, CLASS ATMCaseStudy is the driver class that runs all the other classes. its very urgent. // class ATM import javax.swing.*; import java.awt.*; public
please convert for me this code to GUI - Swing AWT
please convert for me this code to GUI  THE CODES ARE BELOW, CLASS ATMCaseStudy is the driver class that runs all the other classes. its very urgent. // class ATM import javax.swing.*; import java.awt.*; public class ATM
GUI
GUI  How to GUI in Net-beans ... ??   Please visit the following link: http://www.roseindia.net/java/java-tips/background/30java_tools/netbeans.shtml
GUI
GUI  Write a GUI application for the WebBuy Company that allows a user to compose the three parts of a complete email message: the ??To:??, ??Subject:?? and ??Message:?? text. The ??To:??, and ??Subject:?? Text areas
GUI framework
GUI framework  what do u mean by GUI framework
GUI component
GUI component  How can a GUI component handle its own events
gui question
gui question  design a gui application for me and write its code in which the user enters a no. in a textfield and onn clicking the button the sum of the digits of the no. should be displayed. hint: suppose the user enters 12
GUI problem
GUI problem  Create a class called CDProgram and write a GUI program to compute the amount of a certificate of deposit on maturity. The sample data follows: Amount deposited: 80000.00 Years: 15 Interest Rate: 7.75 Hint
java gui
java gui   friends... good day.. i have doubt in java gui. ? i created 1 java gui application. That has two text fields jtext1,jtext2. case: user entered value in first textfield(jtext1) and pressed the enter key . the cursor
Version of gj-gui>gj-gui dependency
List of Version of gj-gui>gj-gui dependency
Java GUI
Java GUI  1) Using Java GUI, create a rectangular box that changes color each time a user click a change color button. 2) Modify Question 1 to include a new button named insert image, that allow user to insert a bitmap image
Maven Repository/Dependency: gj-gui | gj-gui
Maven Repository/Dependency of Group ID gj-gui and Artifact ID gj-gui. Latest version of gj-gui:gj-gui dependencies. # Version... in Eclipse? Maven 3 Tutorial Convert Maven project to Eclipse Web Project
gui question
gui question  design a gui application and write code to accept a string from the user in a textfeild and print using option pane whether it is a palindrome or not. hint: abba is a palindrome   import java.awt.*; import
GUI problem
GUI problem  How do I make a Jbutton which is shaped like a circle. This button needs to be clicked in order to change color.   import java.awt.*; import java.awt.geom.*; import javax.swing.*; public class
Netbeans GUI Ribbon
Netbeans GUI Ribbon  how to create ribbon task in java GUI using netbeans

Ads