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 = totalMarks; //"this" keyword refer to
current instance of the method on
which it is use
}
public double getTotalMarks() {
return totalMarks;
}
public void setGrade(String grade) {
this.grade = grade;//"this" keyword refer to
current instance of the method on
which it is use
}
public String getGrade() {
return grade;
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter number of students in class: ");
int num = input.nextInt();
StudentGrade data[] = new StudentGrade[num];
for (int a = 0; a < data.length; a++) {
System.out.print("Enter student
programming marks: ");
double marks = input.nextDouble();
data[a] = new StudentGrade();
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+");
}
int grade1 = 0;
int grade2 = 0;
int grade3 = 0;
int grade4 = 0;
for (int a = 0; a < num; a++) {
StudentGrade show = data[a];
String i = show.getGrade();
if (i.equals("A+")) {
grade1++;
}
if (i.equals("A")) {
grade2++;
}
if (i.equals("D")) {
grade3++;
}
if (i.equals("E")) {
grade4++;
}
}
System.out.println("Student that
getting A and A+ grade: "
+ (grade1 + grade2));
System.out.println("Student that
getting D and E grade: "
+ (grade3 + grade4));
}
}
thanks
View Answers
November 9, 2011 at 11:15 AM
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class StudentGrade {
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());
StudentGrade data[] = new StudentGrade[num];
for (int a = 0; a < data.length; a++) {
String input=JOptionPane.showInputDialog(null,"Enter student programming marks: ");
double marks = Double.parseDouble(input);
data[a] = new StudentGrade();
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+");
}
int grade1 = 0;
int grade2 = 0;
int grade3 = 0;
int grade4 = 0;
for (int a = 0; a < num; a++) {
StudentGrade show = data[a];
String i = show.getGrade();
if (i.equals("A+")) {
grade1++;
}
if (i.equals("A")) {
grade2++;
}
if (i.equals("D")) {
grade3++;
}
if (i.equals("E")) {
grade4++;
}
}
JOptionPane.showMessageDialog(null,"Student that getting A and A+ grade: " + (grade1 + grade2));
JOptionPane.showMessageDialog(null,"Student that getting D and E grade: "+ (grade3 + grade4));
}
});
}
}
Related Tutorials/Questions & Answers:
Advertisements
Convert the code to GUI ??Convert the
code to
GUI ?? hi >>
can anyone help me to conver this
code to
GUI ??
/**
* @(#)RegistorClass.java
*
*.
* @author...("*** Invalid operation
code ***");
halt= true; // break
Convert the code to GUI Convert the
code to
GUI can any one
convert My
code to
GUI code...: System.out.println("*** Invalid operation
code... ??? System.out.println(); } } `print("
code sample");`
thanks
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...; default: System.out.println("*** Invalid operation
code HOW TO CONVERT THIS CODE INTO GUIHOW 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 GUIconvert 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 GUIconvert 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 GUIconvert 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 GUIconvert 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 GUIconvert 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 GUIconvert 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 GUIconvert 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 GUIconvert 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 GUIconvert 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 GUIconvert 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 GUIconvert 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 GUIconvert 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
"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 AWTplease
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 AWTplease
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
convert to GUIconvert 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
Java GUI codeJava
GUI code Write a
GUI program to compute the amount of a certificate of deposit on maturity. The sample data follows:
Amount deposited... the following
code:
import java.awt.*;
import javax.swing.*;
import java.awt.event.
covert this code to GUIcovert 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
covert this code to GUIcovert 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
GUI convert to celsius program - Java BeginnersGUI convert to celsius program how to write java
GUI program to
convert Fahrenheit to Celsius that need user to input value of Fahrenheit... friend,
Code to
convert Fahrenheit to Celsius :
import java.awt.
Rental Code GUI - Java BeginnersRental
Code GUI dear sir...
i would like to ask some
code of java
GUI form that ask the user will choose
the menu to input
Disk #:
type:
title:
record company:
price:
director:
no. of copies
Java GUI code- creating a circleJava
GUI code- creating a circle My assignment is to write a program..., and area. I did my
code but I can't seem to figure out the mathematical
code...;
//
GUI components
JLabel lClx, lCly, lCircumrx, lCircumry, lRadius
GUI and how to convert a distance - Java BeginnersGUI 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 Catching Exceptions in GUI Code - Java Tutorials
.style1 {
text-align: center;
}
Catching uncaught exception in
GUI
In this section, we will discuss how to catch uncaught exceptions in
GUI.
Lets see the given below
code to identify the uncaught exception :
import
GUIGUI How to
GUI in Net-beans ... ??
Please visit the following link:
http://www.roseindia.net/java/java-tips/background/30java_tools/netbeans.shtml
GUIGUI 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
how to convert war file into .exe file using java codehow to
convert war file into .exe file using java code hi,I am beginner in the java,I want to
convert my java maven project to .exe file,plz tell me which is required jar files and how i
convert this..?Thanks in advance
gui questiongui 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