#C11351. Calculate Shipping Cost
Calculate Shipping Cost
Calculate Shipping Cost
You are given a shipping cost calculator problem. A package is shipped to one of the following destinations with corresponding rates per kilogram:
- switzerland: \(5.00\)
- germany: \(4.00\)
- france: \(4.50\)
- italy: \(6.00\)
- spain: \(5.50\)
- portugal: \(5.75\)
- austria: \(4.25\)
Every shipment also incurs a base cost of (10.00). The total shipping cost is calculated by the formula:
[ \text{Total Cost} = 10.00 + (\text{Rate per kilogram} \times \text{Weight}) ]
Your task is to write a program that reads the destination and the weight of the package from standard input. If the destination is one of the allowed countries and the weight is a positive number, compute and output the shipping cost formatted to two decimal places. Otherwise, output an error message: print "Invalid destination" if the destination is not in the list or "Invalid weight" if the weight is not positive.
inputFormat
The input is read from standard input and consists of two lines:
- The first line contains a string representing the destination country.
- The second line contains a positive floating-point number representing the weight of the package in kilograms.
outputFormat
Output the total shipping cost formatted to two decimal places if the inputs are valid. If the destination is not supported, output "Invalid destination". If the weight is non-positive, output "Invalid weight".## sample
germany
2
18.00