Question

1. Write a function called compute_discount which takes a float as the cost and a Boolean...

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.

Homework Answers

Answer #1

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)));
    }
}
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Define a function math(num1, num2, operation) that takes three arguments and it should perform math operations...
Define a function math(num1, num2, operation) that takes three arguments and it should perform math operations ( +,-,* and /) on two numbers num1 and num2 based on the operation symbol, and then it should return the result. The main part of the program should prompt users to provide num1, num2, and an operation symbol separately and then call the function with user inputs and display the result back to the user. Function definition should look like this in your...
Write C++ code to: Create a function called “ReadFile” that: Accepts a filename as input Opens...
Write C++ code to: Create a function called “ReadFile” that: Accepts a filename as input Opens the file for reading Reads an integer from the file and returns it. Create a main function that Asks the user to input a file Passes that file to the “ReadFile” function Prints the returned integer to the screen Extra Credit: Set a default argument of “intfile.txt” for the “ReadFile” function Write an overloaded function of “ReadFile” that accepts two filenames and reads an...
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns...
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns the index of the first occurance of the smallest value in the array. Your function must be able to process all the elements in the array. Create a function prototype and function definition (after the main function). Your main function should declare a 100 element integer array. Prompt the user for the number of integers to enter and then prompt the user for each...
Function Example: Write a Python function that receives two integer arguments and writes out their sum...
Function Example: Write a Python function that receives two integer arguments and writes out their sum and their product. Assume no global variables. def writer(n1, n2): sum = n1 + n2 product = n1*n2 print("For the numbers", n1, "and", n2) print("the sum is", sum) print("and the product is", product) ... 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both...
1-Create a week_tuple and assign the days of the week as strings to the week_tuple. b....
1-Create a week_tuple and assign the days of the week as strings to the week_tuple. b. Print out the elements in the week_tuple. 2-a. The following list has been declared as follows: credit_list = [24,3,15] b. Convert the credit_list to a tuple named credit_tuple. c. Print out the elements in the credit_tuple. 3-a. Write an initialize_list_values function that takes in a number for the number of elements in a list and an initial value for each element. The function creates...
TO BE DONE IN PYTHON: Write a function `lowest_integer()` which takes 2 input arguments: 1)a function...
TO BE DONE IN PYTHON: Write a function `lowest_integer()` which takes 2 input arguments: 1)a function `g` representing an increasing function g(x) 2) a number `gmin`, and returns an integer `nmin` such that nmin>0 is the smallest integer that satisfies g(nmin)>gmin. test: def g(n): return 2*n print(lowest_integer(g, 10)) Output: 6
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first,...
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first, third, fifth (and so on) characters of the strings, with each character both preceded and followed by the ^ symbol, and with a newline appearing after the last ^ symbol. The function returns no value; its goal is to print its output, but not to return it. Q2) Write a Python function called lines_of_code that takes a Path object as a parameter, which is...
Questions: 1. (5 marks) Create a VB.NET Console Application that defines a function Smallest and calls...
Questions: 1. Create a VB.NET Console Application that defines a function Smallest and calls this function from the main program. The function Smallest takes three parameters, all of the Integer data type, and returns the value of the smallest among the three parameters. The main program should (1) Prompt a message (using Console.WriteLine) to ask the user to input three integers. (2) Call the built-in function Console.ReadLine() three times to get the user’s input. (3) Convert the user’s input from...
1.Write a function which takes a string that contains two words separated by any amount of...
1.Write a function which takes a string that contains two words separated by any amount of whitespace, and returns a string in which the words are swapped around and the whitespace is preserved. Hint: use regular expressions where \s detects the whitespaces in a string. Example: given "Hello     World", return "World         Hello" 2.Pandas exercises: Write a python program using Pandas to create and display a one-dimensional array-like object containing an array of data. Write a python program using Pandas to...
A. Write C code to create a structure called time_of_day, which stores the current time in...
A. Write C code to create a structure called time_of_day, which stores the current time in hours, minutes, and seconds. All the fields should be integers except for seconds, which should be a floating point value. B. Write a C function called check_time, which takes a pointer to a time_of_day structure as input, and return 1 if the time is valid (0 to 23 hours, 0 to 59 minutes, 0 to 59.999999 seconds) and 0 otherwise. Assume that times are...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT