|
|
#1 (permalink) |
|
Silver Member
![]() Join Date: May 2009
Location: USA
Age: 19
Posts: 107
|
I need help with the below. I have part 1C completed, but dont know how to do the rest....can someone help me out. This is the code I currently have
// These are classes needed for this applet to execute. import java.awt.*; import java.applet.*; import java.awt.event.*; // You are extending the Applet class into your Proj1_1 class. public class assignment2_part1_C extends Applet implements ActionListener { // These are the data members of your class. // The doubles are primitive data types, the other a Label, the // third a TextField. double MI, KM; Label prompt; TextField input; // This method will perform what you need done as your Applet // initializes. public void init() { // This creates and places a new Label in your applet. prompt = new Label ("Enter the amount of dollars you have: "); add(prompt); // This creates and places a new TextField in your applet. input = new TextField(5); add(input); // This starts your applet listening for action regarding the // TextField input.addActionListener(this); } // This method describes what actions will be performed by this // class. public void actionPerformed (ActionEvent e) { MI = Integer.parseInt(input.getText()); KM = MI * .681106116; repaint(); } // This method "paints" a message within your applet. public void paint (Graphics g) { g.drawString ("You have € " + KM + " Euros.", 70, 75); } } These are the instructions: Part 1. General Programming Problem (worth 15 points) Find the formula to convert dollars to euros using a current exchange rate and write a program that prompts the user to enter a dollar amount; accepts the user’s input and produces output in euros with the following string message “You entered X dollars which equals Y euros” where X is the number of dollars and Y is the converted amount in euros rounded to two decimals and uses both the dollar and the Euro symbol as part of the output for each respective currency. For example: You entered $4.00 dollars which equals €5.12 euros. Create three versions of the program using the following forms: A. A pure application where the command line prompt is used for input and output B. An application using JOptionPane to use dialog boxes C. An applet Part 2. Create a Java application that performs the following equations where ? will display the answer. Don’t forget to also show the equation in the output as well and let Java calculate the answers for you. There is more than one way to solve this problem: (worth 5 points) A. ? = 3 + 6 x (5 + 4) ÷ 3 – 7 B. ? = 9 - 5 ÷ (8 - 3) x 2 + 6 C. ? = 150 ÷ (6 + 3 x 8) – 5 D. ? = 1 x (3 – 1) x 4 - 2^2 E. ? = 8%3 Part 3. Create an application that has a named constant (a) of 3.123456789012345678901234567890 using double as the data type. Convert the constant an integer and display the result. (worth 5 points) *** For brownie points; add a ‘close button’ to the applet in Part 1C.****
__________________
Case: Thermaltake Xaser VI VG4000BWS | PSU: Corsair 1000HX (1000W) | HDD: Western Digital 300GB (10,000 RPM) | Processor: Intel i7 920 OC @ 3.0ghz | Mobo: ASUS Rampage II Extreme LGA 1366 Intel X58 | Graphics Card: EVGA GeForce GTX 295 (1792MB 896 Bit GDDR3) | Memory: Corsair Dominator GT 6GB | OS: Windows Vista Ultimate 64-bit | Liquid Cooling: CoolIT Systems Domino A.L.C | Gaming NIC: Killer Xeno Pro |
|
|
|
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Java Programming - CITY JUMPER | shariq | General Software | 1 | 01-19-2007 08:34 AM |
| Java Programming - Need URGENT help with CITY JUMPER - Java Programming | shariq | Computer Games and Consoles | 0 | 01-19-2007 08:05 AM |
| What does basic Java Programming language actually look like? | leeroyMarv | General Software | 3 | 06-09-2006 04:48 AM |
| Uni java programming project | Livzz | General Software | 1 | 05-23-2006 12:01 PM |
| JAVA Programming | shupola | General Software | 9 | 10-11-2005 07:42 AM |