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
What could be a pass word if the hint is stayton its for windows 10 <br><br> please help
Alina [70]
Stayton is a city in Oregon, so maybe something to do with that?? I’m sorry I have no clue
8 0
3 years ago
Internet transportation exchanges brings together shippers who post __________ and carriers that post __________ in order to arr
zmey [24]

Answer:

Internet transportation exchanges brings together shippers who post LOADS and carriers that post their AVAILABLE CAPACITY in order to arrange shipments. Group of answer choices capacity, capacity loads, loads capacity, loads loads, capacity

7 0
2 years ago
What are some programs that you have used that have condition-controlled loops and count-controlled loops?
gladu [14]

Some programs that we have used that have condition-controlled loops and count-controlled loops due to the following reasons.

Explanation:

Condition-controlled loops

A program could be made more intelligent by programming it to avoid hazards. For example, if the robot vehicle is 3 cm from the edge of the table and you tell it to move forwards 5 cm, it will drive off the edge of the table. To stop this from happening, you might write a condition-controlled loop like this:

move forward

repeat until (touching table edge)  

Condition-controlled loops can be used to add a high degree of intelligence to a computer system.

Count Controlled Loops

A count controlled loop is a repetition  structure that iterates a specific number of  times

You can write a count controlled loop using a

while() loop.

For example:

counter = 0

while counter < 5:

print (“This will print 5

times”)

counter += 1

8 0
3 years ago
What should be a technicians first step in an A/C system
irina [24]

Perform a visual inspection

3 0
3 years ago
When a field is declared static there will be ________. Group of answer choices two reference copies of the field for each metho
anygoal [31]

Answer: one field copy gets generated in memory

Explanation:

When a field is declared static,it will become common for entire class instances. Single copy of field that gets created for the particular class where numerous instances present in that class can use it by sharing .

  • Other options are incorrect because  two copy of reference does not gets created as it only supports single copy.
  • Copy of the field for every class is not generated by static field.All method and instances use  only one field copy for the whole class.
  • Thus the correct answer is creation of only one field copy in memory for static field.

7 0
3 years ago
Other questions:
  • If a computer file will not open, what should you do? A. Make sure you have the correct software to open it. B. Change the name
    9·1 answer
  • Marco is ready to create his first slide. He wants to put the title of the
    11·1 answer
  • The Printer Event 1 P1 requests and is allocated the printer R1. 2 P1 releases the printer R1. 3 P2 requests and is allocated th
    10·1 answer
  • The ___________ button represents the start of a hyperlink in Table of contents.
    7·1 answer
  • Within a table, the intersection of a row and a column creates a(n) ____.
    13·1 answer
  • Which of the following statements is true regarding Wireshark?
    11·1 answer
  • Help pleaseeeeeeeeeeeeeeeeee
    7·1 answer
  • How am I supposed to delete my Brainly account if I don't know my password and my E-mail is made up?
    13·2 answers
  • Read the problem listed below. Formulate a Decomposition or Outline of the problem. Determine if you have seen this problem befo
    15·1 answer
  • Keith would like to compare data he has collected from research. The data includes the electrical output
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!