1. Write a function called compute_discount which takes a float as the cost and a Boolean value to indicate membership. If the customer is a member, give him/her a 10% discount. If the customer is not a member, she/he will not receive a discount. Give all customers a 5% discount, since it is Cyber Tuesday. Return the discounted cost. Do not prompt the user for input or print within the compute_discount function. Call the function from within main() and pass in 150.78 and True. Call the function from within main() and pass in 98.23 and False. Print out the returned discounted cost with two decimal places of precision in the main function.
2. Add annotations and comments to the compute_discount()
function. Call the appropriate functions from within main() to
display the annotations and comments and print the output.
3. a. Create a new file (module) named camera_picture.py.
b. Write a function, take_picture_effect, that takes two
parameters, the filename and an effect.
c. Take a picture with the filename and effect. Use camera.effect
to set the effect. Use help(PiCamera) to find the effects which you
can apply.
d. Create a second file use_camera.py.
e. Import the take_picture_effect function from the camera_picture
module.
f. Prompt the user for the filename.
g. Prompt the user for the image_effect. help(PiCamera) to see the
list of image effects.
h. Call the function with the filename and the effect as
arguments.
3. Write a function that prints a menu that allows the user to
select an effect with a letter. Call the take_picture_effect
function with the appropriate arguments.
a. cartoon
b. pastel
c. emboss
etc.
1. The coding has been performed in Java
class discount{
public float compute_discount(float cost, boolean member){
float discount;
if (member){
discount = (10*cost)/100;
cost-=discount;
}
//If not a member -
else{
//Discount still given because of CYber Tuesday
discount = (5*cost)/100;
cost-=discount;
}
return cost;
}
public static void main(String at[]) throws Exception{
DecimalFormat df = new DecimalFormat("###.##");
df.setRoundingMode(RoundingMode.CEILING);
System.out.println("Discounted Cost", df.format(compute_discount(150.78,true)));
System.out.println("Discounted Cost", df.format(compute_discount(98.23,false)));
}
}
Get Answers For Free
Most questions answered within 1 hours.