1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Soloha48 [4]
4 years ago
7

In this scenario, two friends are eating dinner at a restaurant. The bill comes in the amount of 47.28 dollars. The friends deci

de to split the bill evenly between them, after adding 15% tip for the service. Calculate the tip, the total amount to pay, and each friend's share, then output a message saying "Each person needs to pay: " followed by the resulting number.

Computers and Technology
2 answers:
pickupchik [31]4 years ago
5 0

Answer:

The java program for the given scenario is as follows.

import java.util.*;

import java.lang.*;

public class Main

{

   //variables for bill and tip declared and initialized

   static double bill=47.28, tip=0.15;

   //variables for total bill and share declared

   static double total, share1;

public static void main(String[] args) {

    double total_tip= (bill*tip);

    //total bill computed

    total = bill + total_tip;

    //share of each friend computed

    share1 = total/2;

    System.out.printf("Each person needs to pay: $%.2f", share1);  

}

}

Explanation:

1. The variables to hold the bill and tip percent are declared as double and initialized with the given values.

static double bill=47.28, tip=0.15;

2. The variables to hold the values of total bill amount and total tip are declared as double.

3. All the variables are declared outside main() and at class level, hence declared as static.

4. Inside main(), the values of total tip, total bill and share of each person are computed as shown.

double total_tip= (bill*tip);

total = bill + total_tip;

share1 = total/2;

5. The share of each person is displayed to the user. The value is displayed with only two decimal places which is assured by %.2f format modifier. The number of decimal places required can be changed by changing the number, i.e. 2. This format is used with printf() and not with println() method.

System.out.printf("Each person needs to pay: $%.2f", share1);  

6. The program is not designed to take any user input.

7. The program can be tested for any value of bill and tip percent.

8. The whole code is put inside a class since java is a purely object-oriented language.

9. Only variables can be declared outside method, the logic is put inside a method in a purely object-oriented language.

10. As shown, the logic is put inside the main() method and only variables are declared outside the method.

11. Due to simplicity, the program consists of only one class.

12. The output is attached.

Sergio039 [100]4 years ago
5 0

Answer:

bill =  47.28

tip = bill *.15

total = bill + tip

share = total

print( "Each person needs to pay: "+str(share) )

Explanation:

You might be interested in
2.5 code practice
Mamont248 [21]

Answer:

try declarimg smt before the int eg answer=int(input("your answer"))

7 0
3 years ago
Your child has broken the RJ-45 port of your laptop by sticking clay into it and there are no wireless networks available in you
sesenic [268]

Answer:

آمل أن يساعد هذا Purchase and use a USB to RJ-45 adapter-yes

fiber_manual_record Enable NIC teaming to increase your bandwidth

Explanation:

67.185.94.80

6 0
3 years ago
Why do you lose internet access when you alter the arp to a static address?
Mila [183]
Sometimes you lose internet access because by altering the arp to a static address, there is change during that so u usually lose the i internet access [ hope i’m right ]
6 0
3 years ago
Read 2 more answers
What type of system software manages memory?
Kobotan [32]

Answer:

"Operating System"

Explanation:

6 0
3 years ago
What is by far the most popular dns server software available?.
JulijaS [17]

Answer:

I use the server

8.8.8.8

and

8.8.4.4

Explanation:

6 0
3 years ago
Other questions:
  • 1. Which of the following are considered CAD powerhouses?
    6·1 answer
  • Select the correct answer.
    8·1 answer
  • Select the tips you should follow when creating a newsletter.
    13·1 answer
  • While reviewing some web page code, you notice that the html is written in all lowercase letters. you are not sure which version
    14·1 answer
  • Structured walk-throughs take place throughout the SDLC and are called _____ reviews, depending on the phase in which they occur
    9·1 answer
  • Which line of code will print I like to code on the screen? print("I like to code") print(I like to code) print("I LIKE TO CODE"
    5·2 answers
  • Microprocessors can’t directly understand programming languages, so programs have to be converted into _____________ that corres
    15·1 answer
  • “Artificial intelligence is the tool of education in the near future”. Research on the possibility of “AI technology” in scienti
    15·1 answer
  • The most common clefs for high notes are what?
    6·2 answers
  • What are some example of popular music for teenagers
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!