Question

In this assignment you will use the following concepts from this unit, "The Basics". Looping Conditional...

In this assignment you will use the following concepts from this unit, "The Basics".

Looping
Conditional Branching
Operators
Variables
System Output
Assignment Background

Java Joe has a busy week ahead of him. He would like you to write a program to help keep track of what he is up to! Your job is to write a program that will loop through the 7 days of the week, each time you go through the loop you should count that as moving on to the next day. For each day use conditional branching to complete the goal outlined beside the days below. You will also have to declare and use a double variable called ' Money' to keep track of how much money Joe has, at the end of the week Joe will want to know how much money he has!

Joe starts his week off with $200. He also starts his week on Monday!

These are the goals you much complete for each day:

Monday
Joe decides he will go buy some shoes to help him walk about this week, he finds a pair for $30, not including tax, calculate the total amount of the shoes Joe will pay using the formula TotalCost = Cost * 1.15; Output to the screen what day it is, how much Joe paid for the shoes and how much money he has left.
Tuesday
Joe goes wants to paint his ceiling; he measures the length out to be 12m and the width to be 7m. Calculate the area of his ceiling for him and output to the screen what day it is and the area of Joe' s ceiling.
Wednesday
Joe goes to the Hardware store to buy some paint. If the paint costs $1.13 per square meter, calculate how much Joe needs pay for his paint using Tuesday's measurements and then output to the screen the cost of the paint and how much money Joe has left.
Thursday
Joe has been driving around a lot this week; he needs to fill his gas tank. If it costs Joe $36.40 (remember to take this off of Joe's total money) and gas was 45cents a liter, Output to the screen what day it is, how many liters of gas Joe got and how much money Joe has left.
Saturday
Joe donated $23 to charity, Output to the screen what day it is, and Joe's current money
Sunday
Output to the screen what day it is or ..
Bonus
use the Remainder operator (%) to tell Joe what exact change he has, example: for $12.35 you would have a ten, a toonie, a quarter, and a dime. This may require a loop within a loop and a little bit of problem solving to figure out!**

Remember you must use a loop and Conditional Branching (If statements) to go through the days, and also remember to comment your code! Best of Luck in helping Java Joe. When finished, submit your code an an image shot of your output.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Output

Day: Monday, Total cost of shoes: $34.5, Money left: $165.5 Day: Tuesday, Ceiling Area: 84 sq. meter Day: Wednesday, Total co

Code with comments

public class WeekSchedule{

    public static void main(String[] args) {

        //variable declaration

        double money=200,totalCost=0;

        int area=0;

        //for 7 days

        for(int i=1;i<=7;i++){

            if(i==1){       //day 1

                totalCost = 30 * 1.15;  //total cost

                money-=totalCost;   //update money

                //printing

                System.out.println("Day: Monday, Total cost of shoes: $"+totalCost+",  Money left: $"+money);

            }

            else if(i==2){

                int l=12,w=7;

                area=l*w;   //area

                System.out.println("Day: Tuesday, Ceiling Area: "+area+" sq. meter");

            }

            else if(i==3){

                double paint = area * 1.13; //paint

                money-=paint;

                paint=((int)(paint*100))/100.0;

                System.out.println("Day: Wednesday, Total cost of paint: $"+paint+",  Money left: $"+money);

            }

            else if(i==4){

                double gas=36.40/0.45; //gas

                money-=36.40;

                gas=((int)(gas*100))/100.0;

                System.out.println("Day: Thursday, Total gas: "+(gas)+" litres,  Money left: $"+money);

            }

            else if(i==5){

                System.out.println("Day: Friday,  Money left: $"+money);

            }

            else if(i==6){

                int charity=23;  //charity

                money-=charity;

                System.out.println("Day: Saturday, Money left: $"+money);

            }

            else{

                System.out.println("Day: Sunday, Money left: $"+money);

                //bonus

                int tens=(int)money/10; //tens

                money-=tens*10;

                int toonie=(int)money/2;  //toonie

                money-=toonie*2;

                int quarter=(int)(money/0.25);  //quarten

                money-=quarter*0.25;

                int dime=(int)(money/0.1);  //dime

                money-=dime*0.1;

                int cents=(int)(money*100);  //cents

                

                System.out.print("Joe has ");

                if(tens!=0)

                    System.out.print(tens+" tens  ");

                if(toonie!=0)

                    System.out.print(toonie+" toonie  ");

                if(quarter!=0)

                    System.out.print(quarter+" quarter  ");

                if(dime!=0)

                    System.out.print(dime+" dime  ");

                if(cents!=0)

                    System.out.print(cents+" cents  ");

            }

        }

        

    }

}

For indentation purpose

1 public class MeekSchedule public static void main(String[] args) //varaible declaration double money=200, total cost-e; int

Add a comment
Know the answer?
Add Answer to:
In this assignment you will use the following concepts from this unit, "The Basics". Looping Conditional...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Joe likes to go to an old arcade and play 8 games of Skeeball every day....

    Joe likes to go to an old arcade and play 8 games of Skeeball every day. On average, he wins a prize on 64% of the games he plays. Today, however, he won only 3 of the 8 games he played. This made Joe think that there must be something wrong with how he is throwing the ball today. However, a friend tells him, "You might be throwing the same way you usually do. People will sometimes have a group...

  • Human Resources Management: Please read the case and answer the questions at the end. Joe's Hamburger...

    Human Resources Management: Please read the case and answer the questions at the end. Joe's Hamburger Grill has been doing business in the same location for the past 20 years. The Grill is located in Phoenix, Arizona, and caters to college students by providing some of the world's biggest hamburgers in a fun and casual dining atmosphere. Joe looks back with fondness on the 20 years that have passed since he first opened the grill. His primary motivation for starting...

  • Answer the following simple interest questions: 1. Jeff borrowed $25 from his dad to buy a...

    Answer the following simple interest questions: 1. Jeff borrowed $25 from his dad to buy a fishing license and promised to pay his dad back in one month. His dad agreed, but said that Jeff must pay 15% annual interest. How much interest will Jeff pay? 2. Anna Maria applied for and received a loan to pay for college. She borrowed $25,000. She must pay the loan back in five years with annual interest of 4%. How much money will...

  • Joe Withers, a 38 year old male, is just about to complete his shift after working...

    Joe Withers, a 38 year old male, is just about to complete his shift after working a busy shift as a restaurant manager in one of the city' busiest restaurants. As he completing his paperwork, he feels a a pounding headache coming on and feels nauseous. Completed with his duties, he clocks out and gets in his car to drive home. He feels sweaty and weak and can't concentrate enough to start the car. A coworker, on his way out...

  • It is midmorning on the cardiac unit where you work, and you are getting a new...

    It is midmorning on the cardiac unit where you work, and you are getting a new patient. G.P. is a 60-yr old retired businessman, who is married and has 3 grown children. As you take his health history, he tells you that he began feeling changes in his heart rhythm about 10 days ago. He has hypertension (HTN) and a 5-yr history of angina pectoris. During the past week, he has had frequent episodes of mid-chest discomfort. The chest pain...

  • Case Study num22 please answer 1-6 Diabetes Mellitus Diabetes mellitus is a common chronic disease, and...

    Case Study num22 please answer 1-6 Diabetes Mellitus Diabetes mellitus is a common chronic disease, and every health professional will need to understand how it works and identify common emergency situations related to it. But an equally important part of the health professional's role is patient education and explaining what happens in the disease process. After they go home, diabetes patients will have to manage this complex disease every day. You are working in the free clinic when Father X...

  • Scenario 1: It is midmorning on the cardiac unit where you work, and you are getting a new patient. G.P. is a 60-yr...

    Scenario 1: It is midmorning on the cardiac unit where you work, and you are getting a new patient. G.P. is a 60-yr old retired businessman, who is married and has 3 grown children. As you take his health history, he tells you that he began feeling changes in his heart rhythm about 10 days ago. He has hypertension (HTN) and a 5-yr history of angina pectoris. During the past week, he has had frequent episodes of mid-chest discomfort. The...

  • 3 points (tra Credit Farmer jo buy for his farm from the local cooper 1.000 gallons...

    3 points (tra Credit Farmer jo buy for his farm from the local cooper 1.000 gallons a month. The coon charges him $700.00 per order when the orders and to 31.0 per gallon per year to share the gas at his farm. The coop can arrive within an hour of the order and joe only has e 500 gallon tank he can How much fuel should jo order every time he place an order? Excel Access Blackboard + → XCO...

  • PN 105 Fundamentals of Nursing I Campus Lab Activity - Low Sodium Diet You are the...

    PN 105 Fundamentals of Nursing I Campus Lab Activity - Low Sodium Diet You are the nurse working with Dr. John Hampsey in his office. A 67-year- old patient Mr. Joseph Banks, has the diagnosis of Congestive Heart Failure. He is compliant with his medications, but the physician suspects he is not compliant with his diet. Upon completing a nutritional assessment and having the patient keep a food diary for one (1) week, it obviously his diet. He prefers sandwiches...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT