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 new information, strategies, or techniques have you learned that will increase your technology skills?
marshall27 [118]
You can try programming
6 0
3 years ago
Hi there are many annoying people in brainly making my head ache
iris [78.8K]

Answer:

Lol who is bothering you?

Explanation:

4 0
3 years ago
Read 2 more answers
A ____ is a set of software tools used by an attacker to hide the actions or presence of other types of malicious software, such
finlep [7]

Answer:

A <u>rootkit</u> is a set of software tools used by an attacker to hide the actions or presence of other types of malicious software, such as trojans, viruses, or worms.

Explanation:

A <u>rootkit</u> is a set of software tools used by an attacker to hide the actions or presence of other types of malicious software, such as trojans, viruses, or worms. Where a Rootkit provides features like remote access to users, it also opens ways for attackers. It helps in hiding the malicious software. Rootkits can be installed on the victim systems by phishing attack or social engineering techniques ..

6 0
3 years ago
If a license carries a " no derivative works" requirement, what terms does it set for using material with that license? A) It re
defon

Answer:

the answer would be c

Explanation:

6 0
2 years ago
A list contains the following items: Antelope, Baboon, Cheetah, Elephant, Giraffe, Hippo, Jackal, Lion, Okapi, Warthog. ​(a)​A b
Alex Ar [27]

Answer:

Antelope Baboon Cheetah Elephant Giraffe, first, then it would search Warthon then Okapi, the manner of a binary search essentially splits the list in half and goes from right to left and then does the same to the other side.

Explanation:

6 0
3 years ago
Read 2 more answers
Other questions:
  • True/False: If a function is legally prototyped to return an integer value, it can return a structure member that is an integer
    11·1 answer
  • _______________creates new markets separate to the mainstream; markets that are unknowable at the time of the technology's conce
    8·1 answer
  • What encryption method is used by WPA for wireless networks?
    7·1 answer
  • "running computer programs and their data are stored in ___"
    10·2 answers
  • a rule that states each foreign key value must match a primary key value in the other relation is called the
    5·1 answer
  • Desirable workplace habits and skills include:
    14·1 answer
  • What is a geam in the ggplot2 system?
    5·1 answer
  • Who wants to be my tutor?
    14·2 answers
  • Complete the statement using the correct term.
    10·1 answer
  • 4.22 lab*: program: automobile service invoice(1) output a menu of automotive services and the corresponding cost of each servic
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!