Question: Modify the code in the following ways: (1) The Copy Cost Problem Write a function that does the following: It should take one parameter, an

Modify the code in the following ways:

(1) The Copy Cost Problem

  • Write a function that does the following:
    • It should take one parameter, an int, that is the number of copies
    • It should return one value, a float64, that is the total charge
    • The same formula should be used as given from previous assignments
  • No literal values should be hard-coded into your program. You must use constants.

Program so far:

package main

import (

"fmt"

)

func main() {

var name string // variables

var copies int

var tprice int

var con string

for

{

fmt.Print("Enter the customer name: ")//get input

//Get customer name

fmt.Scanln(&name)

fmt.Print("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("Customer name:",name)

concatenated := fmt.Sprintf("%s%d", "Total cost: $", tprice)

fmt.Println(concatenated)

fmt.Print("Another customer (Y/N)? ")//get input

//Get customer name

fmt.Scanln(&con)

if con=="N"{

break

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!