Graderpractice for programmers

273387 MAD 63 - Mini Test 1

Awaiting submission
Write a program that converts an amount in Euros to Thai baht. The exchange rate is 1 euro = 36 baht. You program should read in an Int, convert it from euros to baht and then output the result. The output should be formatted as: X euros = Y baht
Awaiting submission
Extend your program to support US dollars and GB pounds. Read in a currency and an amount.

Exchange rates:

  • 1 euro = 36 baht
  • 1 US dollar = 31 baht
  • 1 GB pound = 41 baht
Awaiting submission
Write a function that converts a decimal number (Double) into baht and satang.


func formatBaht(amount: Double) -> String {


let input = Double(readLine() ?? "") ?? 0.0
print(formatBaht(amount: input))
Awaiting submission
Write a function batchConvert that takes an array of Euro amounts (Int) and prints out the converted baht amount followed by the total.


func batchConvert ...

let amounts = (readLine() ?? "").components(separatedBy: ",").map { Int($0) ?? 0 }
batchConvert(amounts: amounts)