Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 i need help with this math crap very badly
Index -> Programming, Turing -> Turing Help
Goto page 1, 2, 3  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
asianrandy




PostPosted: Tue Sep 23, 2008 5:14 pm   Post subject: i need help with this math crap very badly

i have problem making this program.
make a program will look like this plz i need help and thank you for doing this for me.


sample invoice is shown below. you must make the numbers line up in columns without using the locate command. Print two decimal place for all currency.
------------------------------------------------------------------------------------------------------------------

Automatic marking machine
cost: $55.99


customer name : nameless
business name : nameless

number of items ordered: 4

total cost of items : 223.80
postage and handling: 30.00

subtotal: 253.80

5% GST: 15.23
8% PST: 20.30

fianl total: 289.33
Sponsor
Sponsor
Sponsor
sponsor
Saad




PostPosted: Tue Sep 23, 2008 5:23 pm   Post subject: RE:i need help with this math crap very badly

No-one here does work for you, you need to show your work and we can help you. Requesting someone to do so is agains't the rules.
OneOffDriveByPoster




PostPosted: Tue Sep 23, 2008 5:51 pm   Post subject: Re: i need help with this math crap very badly

Does Turing have a "log" function? It could help.
[Gandalf]




PostPosted: Tue Sep 23, 2008 6:09 pm   Post subject: RE:i need help with this math crap very badly

Turing only has a ln(n) function, however I doubt any of that would help as the poster seems to have trouble with "this math crap".

Be more specific in your questions if you want help.
Tony




PostPosted: Tue Sep 23, 2008 6:48 pm   Post subject: RE:i need help with this math crap very badly

well the only "math crap" that's involved in printing an invoice is addition and sometimes multiplication, but only if you want to figure out what the tax is.

(I'm not sure how log is applicable)

@asianrandy -- here's an example that will perhaps help you figure out how to do addition.
Turing:

var item1 : real := 55.99
var item2 : real := 5.99

put "The total of 2 items is: ", item1 + item2


Wink
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
asianrandy




PostPosted: Wed Sep 24, 2008 12:05 pm   Post subject: Re: i need help with this math crap very badly

% This program will print out invoices to send to people with their orders
locate (1, 25)
put "AUTOMATIC MARKING MACHINE"

var name : string
put "Customer Name: "
locate (2, 15)
get name

var total : real := 0
var product : int
loop
put "number of items ordered (1=Computer, 2=computer2, 3=computer3, 4=computer4, 5=postage and handling, 6=quit): " ..
get product
if product = 1 then
total := total + 55.95
elsif product = 2 then
total := total + 111.90
elsif product = 3 then
total := total + 167.85
elsif product = 4 then
total := total + 223.8
elsif product = 5 then
total := total + 30.00
elsif product = 6 then
exit
end if

% The phrase "total : 0 :2" outputs total to two decimal places
put "The running total is $", total : 0 : 2
end loop
put "Final total = $", total : 0 : 2

this is what i got but l'm close to it
asianrandy




PostPosted: Wed Sep 24, 2008 12:07 pm   Post subject: Re: i need help with this math crap very badly

can you give me some tips on turing on addition
Insectoid




PostPosted: Wed Sep 24, 2008 12:12 pm   Post subject: RE:i need help with this math crap very badly

Use another counter to get number of items, then, at the end, cls and print everything the way you want.
Sponsor
Sponsor
Sponsor
sponsor
asianrandy




PostPosted: Wed Sep 24, 2008 12:38 pm   Post subject: Re: i need help with this math crap very badly

i need help where to put the 5%gst and 8%pst and what the code for it

% This program will print out invoices to send to people with their orders
locate (1, 25)
put "AUTOMATIC MARKING MACHINE"

var name : string
put "Customer Name: "
locate (2, 15)
get name


put "Total of items ordered " ..
var number : string
get number
var total : real := 0
var product : int
loop
put "Total Cost of items: " ..
get product
if product = 1 then
total := total + 55.95
elsif product = 2 then
total := total + 111.90
elsif product = 3 then
total := total + 167.85
elsif product = 4 then
total := total + 223.8
elsif product = 5 then
total := total + 30.00
elsif product = 6 then
exit
end if


% The phrase "total : 0 :2" outputs total to two decimal places
put "Total Cost of items: $", total : 0 : 2
end loop
put "6% GST:"

put "Final total = $", total : 0 :
asianrandy




PostPosted: Wed Sep 24, 2008 12:39 pm   Post subject: Re: i need help with this math crap very badly

i dont no how to fix the problem
Euphoracle




PostPosted: Wed Sep 24, 2008 2:29 pm   Post subject: RE:i need help with this math crap very badly

Multiplication in turing is done using an multiplication operator in the form of an asterisk:

Turing:
put "3 x 5 = ", (3 * 5) : 0


Remember, however, that expressing a percentage as a decimal requires you to first divide it by 100. The reasoning for this is the fact that a decimal totals up to 1 (0.5 + 0.5 = 1), whereas percentages total up to 100 (50% + 50% = 100%).

Knowing this, you should be able to calculate 6% GST of the total cost of the items.
asianrandy




PostPosted: Wed Sep 24, 2008 3:08 pm   Post subject: Re: i need help with this math crap very badly

Automatic marking machine
cost: $55.99


customer name : nameless
business name : nameless

number of items ordered: 4

total cost of items : 223.80
postage and handling: 30.00

subtotal: 253.80

5% GST: 15.23
8% PST: 20.30

finall total: 289.33

so far i got is this



var name : string
put "Customer Name: "
locate (1, 15)
get name

var items : string
put "Number of items ordered: "
get items

var total : real := 0
var product : int
loop

get product
if product = 1 then
total := total + 55.95
elsif product = 2 then
total := total + 111.90
elsif product = 3 then
total := total + 167.85
elsif product = 4 then
total := total + 223.8
elsif product = 5 then
total := total + 30.00
elsif product = 6 then
exit
end if


% The phrase "total : 0 :2" outputs total to two decimal places
put "Total Cost of items: $", total : 0 : 2

end loop
put "Final total = $", total : 0 : 2

[size=24]and i ended up [/size]

customer name: myname
number of items ordered: 4

l'm right to get any number i want and get whatever i want too add $ 30.00 then add the subtotal
then calculate the subtotal to get the gst and pst and get the final total.
I have no idea what to do. The Introduction to programming book doesn't tell you what l'm doing.
it quite confusing.
Insectoid




PostPosted: Wed Sep 24, 2008 4:40 pm   Post subject: RE:i need help with this math crap very badly

The introduction to programing (in Turing??) book is utter crap. I assume you're talking about the holtsoft one?

First, you need to use code tags. they work like this:

code:
[code]paste code here[/code]
. This makes it easier for us to read and then find the problem.

Second, I am afraid that if this simple program is this complicated for you, you will not get far in the field. I'm not trying to be mean or anything, but it's the truth.

On to helping! Okay, you are asking the user for the number of items they are ordering. This is bad. Instead, every time they add to the order, add one to 'items' (which has to be an int, you've declared it as a string)

so this:

code:

get product
if product = 1 then
    total := total + 55.95
end if


becomes this:

code:

get product
if product = 1 then
    total += 59.95 %a quick way of saying foo := foo + 1)
    items += 1
end if


It only takes one extra line and streamlines the user's experience.
S_Grimm




PostPosted: Thu Sep 25, 2008 8:38 am   Post subject: RE:i need help with this math crap very badly

insectoid is right. You need a pile of "if" statements (One for each product) and then put them in his code (so instead of "if product = 1 then", you need "if product = 2", "if product = 3", etc..)
SNIPERDUDE




PostPosted: Thu Sep 25, 2008 2:44 pm   Post subject: RE:i need help with this math crap very badly

Or a Case Statement.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 3  [ 32 Posts ]
Goto page 1, 2, 3  Next
Jump to:   


Style:  
Search: