Question
Modify the following Go programs in the following ways: The Copy Cost Problem At the end of the customer output, ask the user if she
Modify the following Go programs in the following ways:
The Copy Cost Problem
- At the end of the customer output, ask the user if she would like to go again
- Have your program loop the inputs, calculations, and outputs for each customer
- Use the Printf function to format your output
- The spacing and formatting precision should exactly mirror that as shown below:
Enter customer name: Mark
Enter number of copies: 40
Customer name: Mark
Total cost: $Z.ZZ
Another customer (Y/N)? Y
Enter customer name: Jill
Enter number of copies: 150
Customer name: Jill
Total cost: $Z.ZZ
Another customer (Y/N)? Y
Enter customer name: Kerryon
Enter number of copies: 87
Customer name: Kerryon
Total cost: $Z.ZZ
Another customer (Y/N)? N
Program so far:
package main
import ( "fmt" ) func main() { var name string // variables var copies int var tprice int fmt.Println("Enter the customer name:")//get input //Get customer name fmt.Scanln(&name) fmt.Println(" Enter the Number of copies:")
//Get total number of copies fmt.Scanln(&copies) // calculate if(copies < 200){ tprice = (copies * 10) } else{ tprice=( 200*10)+(copies-200)*5 } //adds the additional cost fmt.Println(name, "'s total cost is", tprice," cents") }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started