Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C language This homework assignment is about loops. The intention is for you to use a while loop, but the problem can also be

In C language

This homework assignment is about loops. The intention is for you to use a while loop, but the problem can also be solved with a for loop.

The Problem Statement

You and your roommates go through a lot of orange juice. You've noticed that your roommate goes through more orange juice than you do. And when they run out, they will take some of yours.

You have been charging your roommate every time they take some of your orange juice. But it feels a bit silly collecting 50 or 75 cents at a time from them. Youve come up with a brilliant plan! Instead of charging them every time they take your orange juice, youll collect money from them after they have taken 10 dollars worth of juice.

Program Setup

Write a program to mimic this process. Ask the user to enter the size (in ounces) of the juice containers you buy, as well as the price of those containers (in dollars). Then prompt the user to enter how many times the roommate took juice. Finally, read the amount the roommate took each time. Every time the total value of the juice equals or exceeds $10, print out Your roommate owes you $10.00. After all the numbers are entered, if the roommate owes any money, print out the value owed.

Sample Run

What is the weight (in oz.) of the original container of OJ? 64 What is the cost of the original container of OJ in dollars? 3.79 How many times did your roommate take your juice? 10 How much juice did your roommate take this time (in oz.)? 30 How much juice did your roommate take this time (in oz.)? 34 How much juice did your roommate take this time (in oz.)? 24 How much juice did your roommate take this time (in oz.)? 40 How much juice did your roommate take this time (in oz.)? 64 Your roommate owes you $10.00. How much juice did your roommate take this time (in oz.)? 64 How much juice did your roommate take this time (in oz.)? 64 How much juice did your roommate take this time (in oz.)? 18 Your roommate owes you $10.00. How much juice did your roommate take this time (in oz.)? 20 How much juice did your roommate take this time (in oz.)? 20 Your roommate owes you $2.38.

Specification

Homework assignments are either correct or incorrect. You must match these prompts and output formatting including punctuation.

What is the weight (in oz.) of the original container of OJ?

What is the cost of the original container of OJ in dollars?

How many times did your roommate take your juice?

How much juice did your roommate take this time (in oz.)?

Your roommate owes you $X.XX.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Name the steps of the accounting cycle.

Answered: 1 week ago