Prog-2 - Programming Assigment 2 PDF

Title Prog-2 - Programming Assigment 2
Course   Computer Science & Programming
Institution University of Houston
Pages 1
File Size 94.8 KB
File Type PDF
Total Downloads 21
Total Views 152

Summary

Programming Assigment 2 ...


Description

COSC 1306 Assignment 2: Assignment Statement & Expression

[1] Objectives: We are doing very simple computation using assignment statements. This includes reading numbers, writing some expressions, and printing output. You will have to be familiar with operators, precedence, casting input strings into numbers, simple arithmetic, using a math constant PI, importing a module, and a little formatting of output. Some of these stuffs are not fully explained yet. I will give you enough help to complete the work. [2] Requirements: Grocery store normally print a unit price next to the price so that people will be able to compare prices of competing produces (see figure on the right). We want to do that same thing for the pizza store. Assuming that we are selling pizzas in diameters in inches (int). The price of pizza is normally a float such as 9.99. Input the diameter of a pizza and the price of pizza. Then compute the area of the pizza. The unit price of the pizza is the price divided by the area. • • • •

You need to import Math module so that you can use the number PI (math.pi) for calculation of the area. Cast the inputs into integer and float. Print the unit price as cents per square inches with two decimal digit accuracy. Don’t worry about the two decimal digits in your first version. I will help you with the formatting in class. Use an escape character ‘\n’ to add a blank line below the inputs.

[3] Output: A sample execution of the program looks like the figure below.

[4] Deadline: 2:15 pm, Wednesday, February 6, 2019....


Similar Free PDFs