Final Compilation

download Final Compilation

of 40

description

for download purpose only

Transcript of Final Compilation

Final Project in CS315

Prelim: Machine Problem No.1 Displaying InformationCodes:import java.io.*;import javax.swing.JOptionPane;

public class Prelim_MP1{public static void main(String []args)throws IOException {BufferedReader br = new BufferedReader(new InputStreamReader(System.in));System.out.print("\n\t\tOur Lady Of Fatima University");System.out.print("\n\t\t\t Antipolo City");System.out.print("\n\t\t COLLEGE OF COMPUTER STUDIES");String name="";String age="";String birthday="";String address="";String school="";String mother="";String father="";System.out.print("\n\t ----------------------------------------");System.out.print("\n\nEnter your name: ");name = br.readLine();System.out.print("Enter your age: ");age = br.readLine();System.out.print("Enter your birthday: ");birthday = br.readLine();System.out.print("Enter your address: ");address = br.readLine();System.out.print("Enter your school: ");school = br.readLine();System.out.print("Enter your mother's name: ");mother = br.readLine();System.out.print("Enter your father's name: ");father = br.readLine();

System.out.print("\n\n\tMy Name is " + name + ". I am " + age + " years old and my birthday is on " + birthday + ". I lived in " + address + " and studying at " + school + ". My parents's are " + father + " and " + mother +".\n\n"); } }

Prelim: Machine Problem No.1 Displaying InformationOutput:

Prelim: Machine Problem No.2 Displaying with JOptionPaneCodes: import java.io.*;import javax.swing.JOptionPane;

public class Prelim_MP2{public static void main(String[]args) throws IOException{BufferedReader br = new BufferedReader(new InputStreamReader(System.in));System.out.print("\n\t\tOur Lady Of Fatima University");System.out.print("\n\t\t\t Antipolo City");System.out.print("\n\t\t COLLEGE OF COMPUTER STUDIES");

System.out.print("\n\n\t\t PERSONAL INFORMATION");String name="";String age="";String bday="";String address="";String school="";String fder="";String mder="";System.out.print("\n");System.out.print("\n");System.out.print("\n\tName: ");name=br.readLine();System.out.print("\tAge: ");age=br.readLine();System.out.print("\tBirthday: ");bday=br.readLine();System.out.print("\tAddress: ");address=br.readLine();System.out.print("\tSchool: ");school=br.readLine();System.out.print("\tName of your Father: ");fder=br.readLine();System.out.print("\tName of your Mother: ");mder=br.readLine();JOptionPane.showMessageDialog(null, "\t Ako si " +name + ", " + " " + age + " taong gulang.\n" + " Ipinanganak ako noong " + bday + ".\n" + "Nakatira ako sa " + address + ".\n\n" + "\t Ako ay nag-aaral sa " + school + ".\n" + "Ang magulang ko ay sina " + fder + "\nat " + mder + ".");}}Prelim: Machine Problem No.2 Displaying with JOptionPane Output:

Prelim: Machine Problem No.3 Grade ComputationCodes: import java.io.*;import javax.swing.JOptionPane;import java.io.IOException;import java.io.BufferedReader;import java.text.DecimalFormat;

public class Prelim_MP3{public static void main(String[]args)throws IOException{BufferedReader br = new BufferedReader(new InputStreamReader(System.in));int studnum=0;String fname="";String mname="";String lname="";String course="";String section="";float prelim_grade=0;float midterm_grade=0;float final_grade=0;float class_standing=0;float attendance=0;System.out.print("\n\n\t\tGrading System");System.out.print("\n===================================================");System.out.print("\n\nStudent Number: ");studnum = Integer.parseInt(br.readLine());System.out.print("First Name: ");fname= br.readLine();System.out.print("Middle Initial: ");mname= br.readLine();System.out.print("Last Name: ");lname= br.readLine();System.out.print("Course: ");course= br.readLine();System.out.print("Section: ");section= br.readLine();System.out.print("\n\t -------------------------------");System.out.print("\n\n\t\tPrelim Exam: ");prelim_grade = Float.parseFloat(br.readLine());System.out.print("\n\t\tMidterm Exam: ");midterm_grade = Float.parseFloat(br.readLine());System.out.print("\n\t\tFinal Exam: ");final_grade = Float.parseFloat(br.readLine());System.out.print("\n\t\tClass Standing: ");class_standing = Float.parseFloat(br.readLine());System.out.print("\n\t\tattendancedance: ");attendance = Float.parseFloat(br.readLine());DecimalFormat format1=new DecimalFormat("0.00");double finalgrade = 0;finalgrade=((prelim_grade * 0.2) + (midterm_grade * 0.20) + (final_grade * 0.25) +(class_standing * 0.3) + (attendance * 0.05));JOptionPane.showMessageDialog(null, "\t"+studnum +"\n" +lname +", " +fname +", " +mname +"\n" +course +" " +section +"\n\n\tFinal Grade: " +format1.format(finalgrade));if (finalgrade>=101)JOptionPane.showMessageDialog(null, "INVALID GRADE!!!","Message",JOptionPane.ERROR_MESSAGE);else if(finalgrade>=98)JOptionPane.showMessageDialog(null, "RATING: 1.00","Message",JOptionPane.INFORMATION_MESSAGE);else if (finalgrade>=95)JOptionPane.showMessageDialog(null, "RATING: 1.25","Message",JOptionPane.INFORMATION_MESSAGE);else if (finalgrade>=92)JOptionPane.showMessageDialog(null, "RATING: 1.50","Message",JOptionPane.INFORMATION_MESSAGE);else if (finalgrade>=89)JOptionPane.showMessageDialog(null, "RATING: 1.75","Message",JOptionPane.INFORMATION_MESSAGE);else if (finalgrade>=86)JOptionPane.showMessageDialog(null, "RATING: 2.00","Message",JOptionPane.INFORMATION_MESSAGE);else if (finalgrade>=83)JOptionPane.showMessageDialog(null, "RATING: 2.25","Message",JOptionPane.INFORMATION_MESSAGE);else if (finalgrade>=80)JOptionPane.showMessageDialog(null, "RATING: 2.50","Message",JOptionPane.INFORMATION_MESSAGE);else if (finalgrade>=77)JOptionPane.showMessageDialog(null, "RATING: 2.75","Message",JOptionPane.INFORMATION_MESSAGE);else if (finalgrade>=75)JOptionPane.showMessageDialog(null, "RATING: 3.00","Message",JOptionPane.INFORMATION_MESSAGE);elseJOptionPane.showMessageDialog(null, "RATING: 5.00","Message",JOptionPane.WARNING_MESSAGE);}}

Prelim: Machine Problem No.3 Grade ComputationOutput:

Prelim: Machine Problem No.4 Enrollment SystemCodes: import java.io.*;import javax.swing.JOptionPane;import java.io.IOException;import java.io.BufferedReader;import javax.swing.*;import java.text.DecimalFormat;public class Prelim_MP4{public static void main(String[]args)throws IOException{BufferedReader br = new BufferedReader(new InputStreamReader(System.in));int studnum = 0;String name = "";String course = "";int year_level = 0;String answer="";int it1=10000, it2=12000, it3=13000, it4=15000;int hrm1 = 8000, hrm2=9000, hrm3=9500, hrm4=12000;int bsn1=15000, bsn2=16000, bsn3=16500, bsn4=17200;int ba1 = 9000, ba2 =9500, ba3=10000, ba4=10500;int medtech1=14000, medtech2=14300, medtech3=14800, medtech4=15000;int psych1=7000, psych2=7500, psych3=9000, psych4=9500;int pharma1=13000, pharma2=13500, pharma3=14000, pharma4=15000;int pt1=10000, pt2=12000, pt3=12500, pt4=13000;JOptionPane.showMessageDialog(null, " Our Lady of Fatima University \n Antipolo Campus \n\n Enrollment System","Message",JOptionPane.INFORMATION_MESSAGE);System.out.print("\nStudent number: ");studnum = Integer.parseInt(br.readLine());System.out.print("Name: ");name= br.readLine();System.out.print("Year level [1-4]: ");year_level= Integer.parseInt(br.readLine()); do{System.out.print("\n---------------------------------------------------------------");System.out.print("\n\n\t\tCOURSE OFFERED");System.out.print("\n\ta|A - BS Information Technology");System.out.print("\n\tb|B - BS Hotel and Restaurant Management");System.out.print("\n\tc|C - BS Nursing");System.out.print("\n\td|D - BS Business Administration");System.out.print("\n\te|E - BS Business Administration");System.out.print("\n\tf|F - BS Medical Technology");System.out.print("\n\tg|G - BS Psychology");System.out.print("\n\th|H - BS Pharmacy");System.out.print("\n\tj|J - BS Physical Therapy");System.out.print("\n\n\t Choose Course: ");course = br.readLine();char course2=course.charAt(0);System.out.print("\n\n\n\t" +studnum);String name2=name.toUpperCase();System.out.print("\n\t" +name2);DecimalFormat format1=new DecimalFormat("0.00"); if (year_level==1){ System.out.print("\n\tFIRST YEAR! - ");switch(course2){case 'a':case 'A':System.out.print("BS Information Technology");System.out.print("\n\n\tTUITION FEE: "+format1.format(it1));break;case 'b':case 'B':System.out.print("BS Hotel and Restaurant Mngt");System.out.print("\n\n\tTUITION FEE: "+format1.format(hrm1));break;case 'c':case 'C':System.out.print("BS Nursing");System.out.print("\n\n\tTUITION FEE: "+format1.format(bsn1));break;case 'd':case 'D':System.out.print("BS BusinesseAd");System.out.print("\n\n\tTUITION FEE: "+format1.format(ba1));break;case 'e':case 'E':System.out.print("BS Med. Tech.");System.out.print("\n\n\tTUITION FEE: "+format1.format(medtech1));break;case 'f':case 'F':System.out.print("BS Psychology");System.out.print("\n\n\tTUITION FEE: "+format1.format(psych1));break;case 'g':case 'G': System.out.print("BSPH");System.out.print("\n\n\tTUITION FEE: "+format1.format(pharma1));break;case 'h':case 'H': System.out.print("BSPT");System.out.print("\n\n\tTUITION FEE: "+format1.format(pt1)); break;default: System.out.println("invalid input");}}

else if (year_level==2){ System.out.print("\n\tSECOND YEAR! - ");switch(course2){case 'a':case 'A':System.out.print("BS Information Technology");System.out.print("\n\n\tTUITION FEE: "+format1.format(it2));break;case 'b':case 'B':System.out.print("BS Hotel and Restaurant Mngt");System.out.print("\n\n\tTUITION FEE: "+format1.format(hrm2));break;case 'c':case 'C':System.out.print("BS Nursing");System.out.print("\n\n\tTUITION FEE: "+format1.format(bsn2));break;case 'd':case 'D':System.out.print("BS BusinesseAd");System.out.print("\n\n\tTUITION FEE: "+format1.format(ba2));break;case 'e':case 'E':System.out.print("BS Med. Tech.");System.out.print("\n\n\tTUITION FEE: "+format1.format(medtech2));break;case 'f':case 'F':System.out.print("BS Psychology");System.out.print("\n\n\tTUITION FEE: "+format1.format(psych2));break;case 'g':case 'G': System.out.print("BSPH");System.out.print("\n\n\tTUITION FEE: "+format1.format(pharma2));break;case 'h':case 'H': System.out.print("BSPT");System.out.print("\n\n\tTUITION FEE: "+format1.format(pt2)); break;default: System.out.println("invalid input");}}else if (year_level==3){ System.out.print("\n\tTHIRD YEAR! - ");switch(course2){case 'a':case 'A':System.out.print("BS Information Technology");System.out.print("\n\n\tTUITION FEE: "+format1.format(it3));break;case 'b':case 'B':System.out.print("BS Hotel and Restaurant Mngt");System.out.print("\n\n\tTUITION FEE: "+format1.format(hrm2));break;case 'c':case 'C':System.out.print("BS Nursing");System.out.print("\n\n\tTUITION FEE: "+format1.format(bsn3));break;case 'd':case 'D':System.out.print("BS BusinesseAd");System.out.print("\n\n\tTUITION FEE: "+format1.format(ba2));break;case 'e':case 'E':System.out.print("BS Med. Tech.");System.out.print("\n\n\tTUITION FEE: "+format1.format(medtech3));break;case 'f':case 'F':System.out.print("BS Psychology");System.out.print("\n\n\tTUITION FEE: "+format1.format(psych2));break;case 'g':case 'G': System.out.print("BSPH");System.out.print("\n\n\tTUITION FEE: "+format1.format(pharma3));break;case 'h':case 'H': System.out.print("BSPT");System.out.print("\n\n\tTUITION FEE: "+format1.format(pt2)); break;default: System.out.println("invalid input");}}

else if (year_level==4){ System.out.print("\n\tFOURTH YEAR! - ");switch(course2){case 'a':case 'A':System.out.print("BS Information Technology");System.out.print("\n\n\tTUITION FEE: "+format1.format(it4));break;case 'b':case 'B':System.out.print("BS Hotel and Restaurant Mngt");System.out.print("\n\n\tTUITION FEE: "+format1.format(hrm4));break;case 'c':case 'C':System.out.print("BS Nursing");System.out.print("\n\n\tTUITION FEE: "+format1.format(bsn4));break;case 'd':case 'D':System.out.print("BS BusinesseAd");System.out.print("\n\n\tTUITION FEE: "+format1.format(ba4));break;case 'e':case 'E':System.out.print("BS Med. Tech.");System.out.print("\n\n\tTUITION FEE: "+format1.format(medtech4));break;case 'f':case 'F':System.out.print("BS Psychology");System.out.print("\n\n\tTUITION FEE: "+format1.format(psych4));break;case 'g':case 'G': System.out.print("BSPH");System.out.print("\n\n\tTUITION FEE: "+format1.format(pharma4));break;case 'h':case 'H': System.out.print("BSPT");System.out.print("\n\n\tTUITION FEE: "+format1.format(pt4)); break;default: System.out.println("invalid input");}}else{System.out.print("\n\tINVALID!!");}answer = JOptionPane.showInputDialog(null,"Do youwant to try again?[yes/no]:");}while(answer.equalsIgnoreCase("YES"));}}Prelim: Machine Problem No.4 Enrollment System Output:

Midterm: Machine Problem No.1 Quiz ArrayCodes:import java.io.*;import javax.swing.JOptionPane;import java.io.IOException;import java.io.BufferedReader;

public class Midterm_MP1{ public static void main(String args[])throws IOException{ String [][] q; q = new String[10][5]; int score=0; //#1 q[0][0]="One of the first projects developed using Java was.."; q[0][1]="[A] Java"; q[0][2]="[B] Star 7"; q[0][3]="[C] Oak"; q[0][4]="B"; //#2 q[1][0]="Who created Java?"; q[1][1]="[A] James Gosling"; q[1][2]="[B] Dennis Richie"; q[1][3]="[C] Sun Micro Systems"; q[1][4]="A"; //#3 q[2][0]=" Java was created in.."; q[2][1]="[A] 1990"; q[2][2]="[B] 1901"; q[2][3]="[C] 1992"; q[2][4]="B"; //#4 q[3][0]="It was the first name of Java but soon changed because there was already a language called.."; q[3][1]="[A] Oak"; q[3][2]="[B] JRE"; q[3][3]="[C] Java Mobile"; q[3][4]="A"; //#5 q[4][0]="Java can create all kinds of applications that you could create using any conventional programming language ."; q[4][1]="[A] True"; q[4][2]="[B] False"; q[4][3]="[C] I dont know."; q[4][4]="A";//#6 q[5][0]="It is a list of data items that all have the same type and the same name."; q[5][1]="[A] Integer"; q[5][2]="[B] Variable"; q[5][3]="[C] Array"; q[5][4]="C";//#7 q[6][0]="Variables containing an adress to an object in memory."; q[6][1]="[A] Object"; q[6][2]="[B] Object Variable"; q[6][3]="[C] Object Reference Variable"; q[6][4]="C";//#8 q[7][0]=" Meaning of AWT."; q[7][1]="[A] Abstract Window Toolkit"; q[7][2]="[B] Abstract Windowing Toolkit"; q[7][3]="[C] Actual Window Toolkit"; q[7][4]="B";//#9 q[8][0]="Package in AWT that is used to handle events generated by the AWT components ."; q[8][1]="[A] java.awt.events"; q[8][2]="[B] java.awt.event_action"; q[8][3]="[C] java.awt.event"; q[8][4]="C";//#10 q[9][0]="Most frequently used container class."; q[9][1]="[A] Container"; q[9][2]="[B] Panel"; q[9][3]="[C] Components"; q[9][4]="B"; BufferedReader x = new BufferedReader(new InputStreamReader(System.in)); String answer = new String(); System.out.println(); System.out.println("CS315 Java Test"); System.out.println(); for (int i=0; i