Computer Science Canada

Help With Currency Program

Author:  Cloudx99 [ Tue May 26, 2009 10:26 am ]
Post subject:  Help With Currency Program

What is it you are trying to achieve?
I'm trying to make a program that converts currency.


What is the problem you are having?
I'm having problems with the if statements


Describe what you have tried to solve this problem
I've tried what I can do.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


%The "Currency" Program
var name : string
var answer,answer1: string
var CAD,USD,EUR,AUD,Total,Money: real

put "Hello, please enter your name"
get name:*
put "Hello " ..
put name ..
put ", Choose the Currency your converting from"
put "American [USD]"
put "European [EUR]"
put "Australian [AUS]"
get answer
put "Enter the amount of ", answer
get Money


if answer=USD
    Total := Money * 1.1235
    put Total
elsif answer=EUR
    Total := Money * 1.5693
    put Total
elsif answer=AUS
    Total := Money * 0.8771
    put Total
end if



Please specify what version of Turing you are using
4.0.3

Author:  DemonWasp [ Tue May 26, 2009 10:31 am ]
Post subject:  RE:Help With Currency Program

You're mostly right, but you want to put double-quotes (these things: " " ) around USD, EUR and AUS in your if statements. That lets Turing know that they're strings and that you mean to compare the value in your answer variable to the string values "USD", "EUR" and "AUS".


: