
-----------------------------------
asianrandy
Tue Sep 23, 2008 5:14 pm

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

-----------------------------------
Saad
Tue Sep 23, 2008 5:23 pm

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
Tue Sep 23, 2008 5:51 pm

Re: i need help with this math crap very badly
-----------------------------------
Does Turing have a "log" function?  It could help.

-----------------------------------
[Gandalf]
Tue Sep 23, 2008 6:09 pm

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
Tue Sep 23, 2008 6:48 pm

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.

var item1 : real := 55.99
var item2 : real := 5.99

put "The total of 2 items is: ", item1 + item2


;)

-----------------------------------
asianrandy
Wed Sep 24, 2008 12:05 pm

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
Wed Sep 24, 2008 12:07 pm

Re: i need help with this math crap very badly
-----------------------------------
can you give me some tips on turing on addition

-----------------------------------
Insectoid
Wed Sep 24, 2008 12:12 pm

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.

-----------------------------------
asianrandy
Wed Sep 24, 2008 12:38 pm

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
Wed Sep 24, 2008 12:39 pm

Re: i need help with this math crap very badly
-----------------------------------
i dont no how to fix the problem

-----------------------------------
Euphoracle
Wed Sep 24, 2008 2:29 pm

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:

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
Wed Sep 24, 2008 3:08 pm

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]

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
Wed Sep 24, 2008 4:40 pm

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]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:


get product
if product = 1 then
    total := total + 55.95 
end if


becomes this:


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
Thu Sep 25, 2008 8:38 am

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
Thu Sep 25, 2008 2:44 pm

RE:i need help with this math crap very badly
-----------------------------------
Or a Case Statement.

-----------------------------------
asianrandy
Thu Sep 25, 2008 9:21 pm

Re: i need help with this math crap very badly
-----------------------------------
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 += 59.95 
        items += 1
    end if

1 becomes an error and i dont no why.

-----------------------------------
[Gandalf]
Thu Sep 25, 2008 9:38 pm

RE:i need help with this math crap very badly
-----------------------------------
Please use end loop at the end of the program.  Whenever you have a loop you must close it with end loop.

-----------------------------------
S_Grimm
Fri Sep 26, 2008 7:29 am

Re: RE:i need help with this math crap very badly
-----------------------------------
end loop at the end of the program.  Whenever you have a loop you must close it with end loop.[/quote]

He's assuming that the item is already declared in previos lines of code, based on the previous posts.

-----------------------------------
asianrandy
Fri Sep 26, 2008 3:05 pm

RE:i need help with this math crap very badly
-----------------------------------
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
    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 += 59.95 %a quick way of saying foo := foo + 1)
        items += 1
    end if
end loop


1 becomes an error and i dont no y.

lm trying to tell the user how much number of items ordered ex. 4
 and then the total cost of items and it will be like 223.80 and then add shipping and handling which cost 30.00 and get the subtotal and add the 0.14% to the final total.

-----------------------------------
gitoxa
Fri Sep 26, 2008 3:46 pm

RE:i need help with this math crap very badly
-----------------------------------
Your items variable is a string, therefore textual data.  You can't preform math on text.  What you're looking for is to make it an int or nat variable.

As for the rest of your program, you need to think about it logically.  My best interpretation of your program is that you're wanting the user to select what he wants to buy, and the price is added to a total.  You're probably going to want to wait to tell the user how many items they ordered until the end of the program, or atleast until after they've ordered all their products.

-----------------------------------
Insectoid
Fri Sep 26, 2008 6:45 pm

RE:i need help with this math crap very badly
-----------------------------------
You can have nat variables in Turing? I did not know that.

-----------------------------------
S_Grimm
Fri Sep 26, 2008 7:33 pm

RE:i need help with this math crap very badly
-----------------------------------
kool, i didn't eaither... how do you call them\ intizalize them...

-----------------------------------
Insectoid
Fri Sep 26, 2008 7:43 pm

RE:i need help with this math crap very badly
-----------------------------------
var foo : nat := 5?

-----------------------------------
gitoxa
Fri Sep 26, 2008 8:18 pm

RE:i need help with this math crap very badly
-----------------------------------
nat, nat2, or nat1

The number representing the number of bytes used by the variable, nat using 4.

min value - 0
max value - 2^(bytes * 8)

-----------------------------------
[Gandalf]
Fri Sep 26, 2008 8:33 pm

RE:i need help with this math crap very badly
-----------------------------------
Not only can you have nats, you can also specify the amount of memory you wish for them to occupy:
var foo : nat2 := 61241
var bar : int1 := 17

-----------------------------------
asianrandy
Sat Sep 27, 2008 8:53 pm

RE:i need help with this math crap very badly
-----------------------------------
what are nat variable can you give me an example what lm trying to do

-----------------------------------
asianrandy
Sat Sep 27, 2008 9:18 pm

RE:i need help with this math crap very badly
-----------------------------------
put "AUTOMATIC MARKING MACHINE"


var name1, name2 : string := ""
put "Customer Name: " ..
get name1 :*
put "Business Name : " ..
get name2 :*

var total : real := 0
var product : int
loop
    put "number of items ordered : " ..
    get product
    if product = 1 then
        total := total + 59.95
    elsif product = 2 then
        total := total + 119.90
    elsif product = 3 then
        total := total + 179.85
    elsif product = 4 then
        total := total + 239.80
    elsif product = 5 then
        total := total + 299.75
    elsif product = 6 then
        exit
    end if
    put "Total Cost of items: $", total : 0 : 2
    
end loop
put "Final Total = $", total : 0 : 2


i'm very close to finishing this
after put "total cost of items: $", total : 0 : 2
i have no no idea what to do.  i need to put Postage and handing: 30.00 and the subtotal then add 6% and 8 % that where lm stuck at 
and after i will know the final total.

i need some help or tips in order to finishing this assignment on selection. and can you give me links on selection. Thank you.

-----------------------------------
andrew.
Sat Sep 27, 2008 9:44 pm

RE:i need help with this math crap very badly
-----------------------------------
Well, all you need to do is add $30 to total. 

total += 30

Then you have to add 14%. 

total *= 1.14

Then you just output total again. 

put "Your grand total is: $" + total

-----------------------------------
S_Grimm
Sun Sep 28, 2008 2:53 pm

RE:i need help with this math crap very badly
-----------------------------------
put an option for checkout. so, if checkout = true then, shipping tax

-----------------------------------
asianrandy
Sun Sep 28, 2008 7:11 pm

RE:i need help with this math crap very badly
-----------------------------------
Andrew can you put that in a code lm like confused right now.

-----------------------------------
S_Grimm
Mon Sep 29, 2008 10:13 am

Re: i need help with this math crap very badly
-----------------------------------
where your code says

elsif product = 6 then
exit
end if
put "Total cost of items "
end loop

you  need to add

total += 30
total *= 1.14
put "Total after tax is $", total


-----------------------------------
asianrandy
Mon Sep 29, 2008 11:57 am

RE:i need help with this math crap very badly
-----------------------------------
thank man ur the best.
