Java Programming Class

MorningWood

New Member
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.****
 
Top