Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
309 views

Final Exam in CS 122 Java Programming: Submitted By: Abby Rose L. Abraham Bsit 2A Submitted To: Prof. Josan Tamayo

The document contains code for 6 Java applets that allow a user to select options from dropdown menus or checkboxes and display the selection or calculate a total. The applets create user interfaces with components like Labels, TextFields, Choices, Checkboxes, and Canvases. When an option is selected, the applets call methods that output the selection or perform calculations and display the results.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
309 views

Final Exam in CS 122 Java Programming: Submitted By: Abby Rose L. Abraham Bsit 2A Submitted To: Prof. Josan Tamayo

The document contains code for 6 Java applets that allow a user to select options from dropdown menus or checkboxes and display the selection or calculate a total. The applets create user interfaces with components like Labels, TextFields, Choices, Checkboxes, and Canvases. When an option is selected, the applets call methods that output the selection or perform calculations and display the results.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Final Exam in CS 122 Java Programming

Submitted by: Abby Rose L. Abraham BSIT 2A Submitted to: Prof. Josan Tamayo

import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Exam1 extends Applet implements ItemListener { Label lbl=new Label("Total",Label.LEFT); TextField txt=new TextField(15); Checkbox item1=new Checkbox("Extra Rice...Php 5.00"); Checkbox item2=new Checkbox("Softdrink...Php 10.00 "); private Choice choice; public void init() { choice = new Choice(); choice.addItem("Value Meal 1"); choice.addItem("Value Meal 2"); choice.addItem("Value Meal 3"); choice.addItem("Value Meal 4"); choice.addItemListener(this); add(choice); add(item1); add(item2); item1.addItemListener(this); item2.addItemListener(this); addNewLine(); add(lbl); add(txt); txt.getText(); txt.setEditable(false); } public void itemStateChanged(ItemEvent event) { Choice choice = (Choice)event.getSource(); String selection = choice.getSelectedItem(); if (selection.equals("Value Meal 1")) { doChoice1Action(); } else if (selection.equals("Value Meal 2")) { doChoice2Action(); } else if (selection.equals("Value Meal 3")) {

doChoice3Action(); } else if (selection.equals("Value Meal 4")) { doChoice4Action(); } } private void doChoice1Action() { System.out.println("Value Meal 1"); } private void doChoice2Action() { System.out.println("Value Meal 2"); } private void doChoice3Action() { System.out.println("Value Meal 3"); } private void doChoice4Action() { System.out.println("Value Meal 4"); } private void horizontalLine(Color c){ Canvas line=new Canvas(); line.setSize(10000,1); line.setBackground(c); add(line); } private void addNewLine(){ horizontalLine(getBackground()); } } <html> <applet code="Exam1.class" width=200 height=200> </applet> </html>

import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Exam3choice extends Applet implements ItemListener { TextField txtalet=new TextField(15); Label eva=new Label("What is your favorite Network?");

} else if (selection.equals("STUDIO23")) { txtalet.setText("STUDIO23"); } else if (selection.equals("CNN")) { txtalet.setText("CNN"); } } }

private Choice choice; public void init() {

<html> <applet code="Exam3choice.class" width=200 height=200> </applet> </html>

choice = new Choice(); choice.addItem("ABS-CBN"); choice.addItem("GMA7"); choice.addItem("ABC5"); choice.addItem("STUDIO23"); choice.addItem("CNN"); choice.addItemListener(this);

add(eva); add(choice); add(txtalet); } public void itemStateChanged(ItemEvent yo) { Choice emy = (Choice)yo.getSource(); String selection = choice.getSelectedItem(); if (selection.equals("ABS-CBN")) { txtalet.setText("ABS-CBN"); } else if (selection.equals("GMA7")) { txtalet.setText("GMA7"); } else if (selection.equals("ABC5")) { txtalet.setText("ABC5");

import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Exam4 extends Applet implements ItemListener { TextField tres=new TextField(15); Checkbox uno =new Checkbox("ABS-CBN"); Checkbox dos=new Checkbox("GMA-7"); Label quatro=new Label("What is your favorite Network?");

public void init() { add(quatro); add(uno); add(dos); uno.addItemListener(this); dos.addItemListener(this); add(tres); } public void itemStateChanged(ItemEvent yo) { if(uno.getState()) txtStatus.setText("Kapamilya ka!"); else txtStatus.setText("Kapuso ka!");

} } <html> <applet code="Exam4.class" width=200 height=200> </applet> </html>

import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class Exam6 extends Applet implements ItemListener { TextField txtStatus=new TextField(15); CheckboxGroup radioStat=new CheckboxGroup(); Checkbox radionet=new Checkbox("ABSCBN",radioStat,false); Checkbox radionet2=new Checkbox("GMA7",radioStat,false); Label lblfav=new Label("What is your favorite Network?"); public void init() { add(lblfav); add(radionet); add(radionet2); radionet.addItemListener(this); radionet2.addItemListener(this); add(txtStatus); } public void itemStateChanged(ItemEvent it) { if(radionet.getState()) txtStatus.setText("Kapamilya ka!"); else txtStatus.setText("Kapuso ka!"); } } <html> <applet code="Exam6.class" width=200 height=200> </applet> </html>

You might also like