i need to make this plz will give a thumbs up if done good . the link for the st
ID: 3910872 • Letter: I
Question
i need to make this plz will give a thumbs up if done good . the link for the stated code is below: same zip filesor Goal Design an app/site that allow users to vote on their favorite baby names and displays updated statistics of the most popular baby names. It should demonstrate your knowledge of (primarily) PHP, and MySQL and build upon your existing knowledge of HTML, CSS, Bootstrap, JavaScript, and jQuery Recommended Procedure 1. Make sure you have your lamp.cse.fau.edu server space set up. Please refer to detailed instructions and screencasts on Bb, if needed. Please note that you must have a server setup for your PHP code to work. Milestone 1: connection with database (starter code: table Test) 2. Download the tableTest.zip file from Blackboard. It consists of two files: tabletest.php and 3. 4. 5. (under directory php) db_connect.php Update your db_connect.php file with your proper credentials. Upload the two files (maintaining the proper directory structure) to your area on the server Run tabletest.php to test if you can successfully connect to the database. It should show the following: Database Table Test Step One Creating the tab Step Two ring into the table Step Three Rtiving heow FRO TEST
Explanation / Answer
Course.java
package gpacalc;
public class Course {
private String name;
private String grade;
private double credit_hours;
public Course(){
name = "";
grade = "A";
credit_hours = 0.0;
}
public String getName(){
return name;
}
public void setName(String newName){
this.name = newName;
}
public String getGrade(){
return grade;
}
public void setGrade(String newGrade){
this.grade = newGrade;
}
public double getCreditHours(){
return credit_hours;
}
public void setCreditHours(double newCreditHours){
this.credit_hours = newCreditHours;
}
}
========================================================
Semester.java
package gpacalc;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Semester {
public static final int NO_OF_COURSES = 5;
public Course[] courses;
public Semester(){
courses = new Course[NO_OF_COURSES];
for(int i=0;i < NO_OF_COURSES;i++){
courses[i] = new Course();
}
System.out.println("Enter Names of 5 subjects: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] names = new String[NO_OF_COURSES];
try{
for(int i=0;i < NO_OF_COURSES;i++){
names[i] = br.readLine();
}
}
catch(Exception e){
System.out.println("Error");
}
for(int i=0;i < NO_OF_COURSES;i++){
courses[i].setName(names[i]);
}
}
}
===========================================================
GPAcalc.java
package gpacalc;
public class GPAcalc {
public static void main(String[] args) {
// TODO Auto-generated method stub
Semester s = new Semester();
GUI g = new GUI(s);
}
}
====================================================
GUI.java
package gpacalc;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
public class GUI extends JFrame implements ActionListener {
JFrame mainFrame;
JButton calculateBtn, resetBtn;
JTextField[] creditHourTF;
JTextField gpaTF;
JLabel[] courseNameLabels;
JLabel topLabel,gpaLabel,emptyLabel;
JComboBox[] gradeSelect;
Container con,buttons,gpaCon;
public GUI(Semester s){
mainFrame = new JFrame("GPA Calculator");
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
calculateBtn = new JButton("Calculate");
resetBtn = new JButton("Reset");
topLabel = new JLabel("Hello");
con = new Container();
con.setLayout(new GridLayout(Semester.NO_OF_COURSES, 3));
creditHourTF = new JTextField[Semester.NO_OF_COURSES];
courseNameLabels = new JLabel[Semester.NO_OF_COURSES];
gradeSelect = new JComboBox[Semester.NO_OF_COURSES];
String grades[] = {"F","D","C","B","A"};
for(int i=0;i < Semester.NO_OF_COURSES;i++){
courseNameLabels[i] = new JLabel(s.courses[i].getName());
creditHourTF[i] = new JTextField();
gradeSelect[i] = new JComboBox(grades);
con.add(courseNameLabels[i]);
con.add(creditHourTF[i]);
con.add(gradeSelect[i]);
}
buttons = new Container();
buttons.setLayout(new GridLayout(1,2));
buttons.add(resetBtn);
buttons.add(calculateBtn);
gpaLabel = new JLabel("GPA");
gpaTF = new JTextField();
emptyLabel = new JLabel();
gpaCon = new Container();
gpaCon.setLayout(new GridLayout(1,3));
gpaCon.add(emptyLabel);
gpaCon.add(gpaLabel);
gpaCon.add(gpaTF);
mainFrame.setSize(600, 400);
mainFrame.setLayout(new GridLayout(4,1));
mainFrame.add(topLabel);
mainFrame.add(con);
mainFrame.add(gpaCon);
mainFrame.add(buttons);
mainFrame.setVisible(true);
resetBtn.addActionListener(this);
calculateBtn.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getSource() == resetBtn){
for(int i=0;i < 5;i++){
creditHourTF[i].setText("0.0");
gradeSelect[i].setSelectedIndex(0);
gpaTF.setText("0.0");
}
}
if(e.getSource() == calculateBtn){
double sum = 0,unit_sum =0;
for(int i=0;i < 5;i++){
sum += Double.parseDouble(creditHourTF[i].getText()) * gradeSelect[i].getSelectedIndex();
unit_sum += Double.parseDouble(creditHourTF[i].getText());
}
sum = sum / unit_sum;
gpaTF.setText(Double.toString(sum));
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.