GIDForums  

Go Back   GIDForums > Computer Programming Forums > Java Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 24-Sep-2008, 09:33
swoo23 swoo23 is offline
New Member
 
Join Date: Sep 2008
Posts: 3
swoo23 is on a distinguished road

Imitate a cash register transaction


Hi I've been reading around the forums and I've decided to join. I'm a new student in computing and I was wondering if someone could help me out.

Create a Java application project called Exercise1b that imitates a cash register transaction. You should enter the price of the item at the keyboard, calculate the gst (5%) on that price, calculate the total amount due, get the amount tendered from the keyboard, calculate the change due and print out all the results with two decimal places. The output should look like the following (note that user input is in bold type):

Use the following code to input the price and the amount tendered:

JAVA Code:
System.out.print("Please enter the item price>");
Float itemPrice = Keyboard.in.readFloat();

System.out.print("Please enter the amount tendered>");
Float amtTendered = Keyboard.in.readFloat();

Please enter the item price>4.98

Price: 4.98

GST: 0.25

Total: 5.23


Please enter the amount tendered>6.25

Tender: 6.25

Change due: 1.02

How would I write that out?
Last edited by LuciWiz : 24-Sep-2008 at 09:38. Reason: Please insert your Java code between [java] & [/java] tags
  #2  
Old 24-Sep-2008, 09:36
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 1,031
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: Question with Coding


Senior members might not reply to this thread if you:
  • used "Please help", "C problem" or something equally vague as the title for your thread.
  • included example code in your message and not use the syntax highlighting [cpp], [java] etc. tags.
  • did not describe the problem accurately or include the error message (if any).
The guidelines for posting can be found here.

We encourage you to post again once you've done that.
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #3  
Old 24-Sep-2008, 09:39
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 1,031
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: Question with Coding


Show us what you tried.
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #4  
Old 24-Sep-2008, 09:46
swoo23 swoo23 is offline
New Member
 
Join Date: Sep 2008
Posts: 3
swoo23 is on a distinguished road

Re: Question with Coding


# You must use Float objects and float primitive data types to complete this exercise.
# See Floats and floats for more details
# Convert Float from readFloat() to float value to do any math operation, for example:

JAVA Code:
 Float itemPrice = Keyboard.in.readFloat();
 float fItemPrice;
 fItemPrice = itemPrice.floatValue();

# You can convert the float value, fItemPrice into a float value with two decimal places using the expression:

JAVA Code:
    Math.round(fItemPrice*100f)/100f 

Those are the guidelines that I am supposed to follow.

The thing is, I'm really new at this and I was wondering how I would start this code? I'm not sure how I would calculate the GST and the others.
Last edited by LuciWiz : 25-Sep-2008 at 00:24. Reason: Please insert your Java code between [java] & [/java] tags
  #5  
Old 24-Sep-2008, 17:59
swoo23 swoo23 is offline
New Member
 
Join Date: Sep 2008
Posts: 3
swoo23 is on a distinguished road

Re: Imitate a cash register transaction


I also use eclipse to write these codes if that helps.
 
 

Recent GIDBlogNot selected for officer school by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Please, This is Difficult question try for me! bcompt143 C++ Forum 4 24-Aug-2008 09:14
Question about locking surfaces to directly access pixels, SDL. george89 C++ Forum 0 18-Jun-2006 21:16
Coding Contest #1 davis Miscellaneous Programming Forum 0 12-Jun-2006 08:29
Pls help in this coding. harsha C++ Forum 5 08-Apr-2004 20:48
C Coding Style dsmith Miscellaneous Programming Forum 10 24-Feb-2004 06:23

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:37.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.