Okay so I feel pretty bad about making my first post on this site about one pleading for help... but alas, I need help.
On the bright side, it's basically pretty simple questions.
I actually don't know how to phrase this so forgive me! I really am just that new at this stuff :[
Uhm okay, so what I need to do is identify objects, local variables, instance variables, class variables(I don't think I have any of these though), methods, and constants in this code thing. Which I wrote! Yippee!
So basically, I have the textbook definitions and whatnot but it's really not helping.
I'm not sure if what I'm really calling an object or a variable is really that, you know?
So anyway, here's my code:
public class HwkAssignment2Appl extends JFrame
* @param args
//create object of JPanel
JPanel mainPanel = new JPanel();
//create 12 label objects for prompts that let user input three numbers. These three numbers are then added together and then multiplied together to get the tax that would be payed for these objects. The total price of purchase with tax is also displayed. The programmer name is also shown.
JLabel firstNumberPromptLabel = new JLabel("First Number:");
JLabel firstNumberLabel = new JLabel(" ");
JLabel secondNumberPromptLabel = new JLabel("Second Number:");
JLabel secondNumberLabel = new JLabel(" ");
JLabel thirdNumberPromptLabel = new JLabel("Third Number:");
JLabel thirdNumberLabel = new JLabel(" ");
JLabel resultPromptLabel = new JLabel("Result Number:");
JLabel resultLabel = new JLabel(" ");
JLabel nameLabel = new JLabel("Programmer Name: Hira");
JLabel taxNumberLabel = new JLabel("Tax paid on items at 9.25% tax rate:");
JLabel taxLabel = new JLabel(" ");
JLabel additionPromptLabel = new JLabel("Subtotal:");
JLabel additionLabel = new JLabel(" ");
//set the tax rate to .0925
final float TAX_RATE = .0925f;
public static void main(String args)
// create an object of the class and set the close of the X button
HwkAssignment2Appl myApp = new HwkAssignment2Appl();
//add label objects to the panel
//Create 3 String objects to store in the user entry
String num1String, num2String, num3String;
//create 4 floats the user entries and result
float num1Float, num2Float, num3Float, resultFloat;
//create 2 floats for the sum of three numbers inputed by user(additionFloat) and one for the sum of additionFloat and tax(taxFloat)
float additionFloat, taxFloat;
//JOption dialog returns the user entry
num1String = JOptionPane.showInputDialog(null, "Please enter the number");
num2String = JOptionPane.showInputDialog(null, "Please enter the number");
num3String = JOptionPane.showInputDialog(null, "Please enter the number");
//Convert from String object to float
num1Float = Float.parseFloat(num1String);
num2Float = Float.parseFloat(num2String);
num3Float = Float.parseFloat(num3String);
//add the numbers
additionFloat = num1Float + num2Float + num3Float;
//multiply additionFloat by TAX_RATE in order to get the tax of items
taxFloat = additionFloat * TAX_RATE;
//add taxFloat and additionFloat to get the result
resultFloat = additionFloat + taxFloat;
//display the variables in the label objects
resultLabel.setText("" + resultFloat);
taxLabel.setText("" + taxFloat);
additionLabel.setText("" + additionFloat);
//add the panel object to the JFrame object
//set the size and visibility of the JFrame
Please help! ):
I would love you to pieces if you did.
(Please don't think about that statement for more than two seconds. You might realize that it doesn't make sense.. which I sadly do not a vast majority of the time).
Gracias in advance though. Just for even looking at this (wonderful, hilarious, exciting) thread.
Excuse me for a moment while I use this adorable emotican. Heheh. :(emo):
Re: Identifying Objects/Variables
Since this is your project, you absolutely need to show us your attempt to solve this yourself first. If you don't do this, you'd be cheating yourself.
Originally Posted by hiralarious
Re: Identifying Objects/Variables
Mmks, so this is what I have so far then:
oh, almost forgot to ask -
would all the addition stuff and whatnot count as a method or no? I was leaning towards no though, but yeah.