Phase 1: Start by creating a new project in PyCharms and adding a file called final.py In that file add the header information as we do for all assignments as described here: Submission Standards (of course the assignment is Final and include your own information) Then use print and input statements to write a program that will produce the following output: Welcome to the Calculon 5000 What is the path to the bill? C:\Users\0757557\PycharmProjects\GradingCS31\Final\data.txt The path you entered is C:\Users\0757557\PycharmProjects\GradingCS31\Final\data.txt ------------------------------------------------------------------------------------------------------------------------------------ data.txt : prices grapes: 4.00 oranges: 7.50 bread: 3.05 coke: 7.77 beef: 3.75 quantities grapes: 1 bread: 2 coke: 8 beef: 1 ------------------------------------------------------------------------------------------------------------------------------------ Please submit the answer in 'phases' it helps me with understanding what is happening :-) the top one is phase one and the pictures show the rest of the phases of the program after.
Phase 1: Start by creating a new project in PyCharms and adding a file called final.py In that file add the header information as we do for all assignments as described here: Submission Standards (of course the assignment is Final and include your own information) Then use print and input statements to write a program that will produce the following output: Welcome to the Calculon 5000 What is the path to the bill? C:\Users\0757557\PycharmProjects\GradingCS31\Final\data.txt The path you entered is C:\Users\0757557\PycharmProjects\GradingCS31\Final\data.txt ------------------------------------------------------------------------------------------------------------------------------------ data.txt : prices grapes: 4.00 oranges: 7.50 bread: 3.05 coke: 7.77 beef: 3.75 quantities grapes: 1 bread: 2 coke: 8 beef: 1 ------------------------------------------------------------------------------------------------------------------------------------ Please submit the answer in 'phases' it helps me with understanding what is happening :-) the top one is phase one and the pictures show the rest of the phases of the program after.
Phase 1: Start by creating a new project in PyCharms and adding a file called final.py In that file add the header information as we do for all assignments as described here: Submission Standards (of course the assignment is Final and include your own information) Then use print and input statements to write a program that will produce the following output: Welcome to the Calculon 5000 What is the path to the bill? C:\Users\0757557\PycharmProjects\GradingCS31\Final\data.txt The path you entered is C:\Users\0757557\PycharmProjects\GradingCS31\Final\data.txt ------------------------------------------------------------------------------------------------------------------------------------ data.txt : prices grapes: 4.00 oranges: 7.50 bread: 3.05 coke: 7.77 beef: 3.75 quantities grapes: 1 bread: 2 coke: 8 beef: 1 ------------------------------------------------------------------------------------------------------------------------------------ Please submit the answer in 'phases' it helps me with understanding what is happening :-) the top one is phase one and the pictures show the rest of the phases of the program after.
Start by creating a new project in PyCharms and adding a file called final.py
In that file add the header information as we do for all assignments as described here: Submission Standards (of course the assignment is Final and include your own information)
Then use print and input statements to write a program that will produce the following output:
Welcome to the Calculon 5000 What is the path to the bill? C:\Users\0757557\PycharmProjects\GradingCS31\Final\data.txt The path you entered is C:\Users\0757557\PycharmProjects\GradingCS31\Final\data.txt
Please submit the answer in 'phases' it helps me with understanding what is happening :-) the top one is phase one and the pictures show the rest of the phases of the program after.
Transcribed Image Text:### Phase 2:
**Step 1: Add Data File**
- First, add a file to your project called `data.txt` and copy/paste this data to it: [data.txt](#).
**Step 2: Create Class Definition**
- After your current code, please add a class definition with the following characteristics:
- It is named `Calculon5000`.
- It has a constructor that takes a single argument named `mypath`, which contains the path to `data.txt`.
- The constructor opens and reads the flat text into a list named `raw_data` (one line per list item).
- It should catch an exception if the file is not found, print out "Was unable to find {mypath}" and exit gracefully.
- After the class definition, please create an object of type `Calculon5000` named `the_bill` using the path input above.
### Phase 3:
**Step 3: Constructing the Class**
- Continuing in your code, in your constructor for `Calculon5000`:
- Use the items from `raw_data` to populate a new instance variable called `prices_dict`.
- Use the items from `raw_data` to populate a new instance variable called `quantities_dict`.
- Please submit this file here.
- Note: Make sure you are converting everything to the appropriate type as you store it. It should be obvious.
### Phase 4:
**Step 4: Adding Functionality to the Class**
- Continuing to add to your class `Calculon5000`:
- Add a function called `.calculate_bill()` that will return the total bill based upon the price of each item and quantity of each item.
- Then add this print statement to the bottom of your code:
```python
print(f"The total cost is {the_bill.calculate_bill()}")
```
By following these steps, you'll create a robust class to handle reading data, storing it in a structured way, and performing calculations based on that data. This approach leverages exception handling to manage potential issues with file reading and ensures that data is converted into appropriate types for further use.
Transcribed Image Text:### Phase 5:
At the bottom of your code, extend your class `Calculon5000` with a child class `Calculon5001` with the following changes:
- The child class will create an empty dictionary called `discount_dict` in its constructor that will contain discounts on various items.
- The child class will have a new function called `.add_discount(self, product, amount)` that will add the product and discount amount to the `discount_dict`.
- `product` will always be a string matching a product named in `discount_dict`.
- `amount` will always be a float between 0 and 1.0.
- If the amount is .25, that means it is 25% off. So if walnuts were 5.00 and the discount for walnuts was .25, the adjusted price would be 3.75.
- The child class will override the `.calculate_bill()` function to apply the discount appropriately.
Beneath this, add the following code:
```python
new_bill1 = Calculon5001(path)
new_bill1.add_discount('grapes', .1)
new_bill1.add_discount('coke', .75)
print(f"The total cost of the discounted bill is {new_bill1.calculate_bill()}")
```
#### Graphs or Diagrams:
None.
---
### Question 6
#### Phase 6:
Continuing to add to your class `Calculon5001`:
- Add a function called `.print_itemized_bill()` that will print each item in the quantities dictionary on its own line with the following specifications:
- The line will have the item name (left aligned), quantity, price, discount, and line total equally spaced.
- The line will be 80 characters across.
Add this line to the bottom of your code:
```python
new_bill1.print_itemized_bill()
```
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.