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]
3 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]3 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]3 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
PA theme is a major message that a writer convoys through a text. you have explored many themes in the hobbit one theme in the n
Nataly [62]

Answer:

The Hobbit’s main theme is Bilbo’s development into a hero, which more broadly represents the development of a common person into a hero. At the beginning of the story, Bilbo is timid, comfortable, and complacent in his secure little hole at Bag End. When Gandalf talks him into embarking on the quest with Thorin’s dwarves, Bilbo becomes so frightened that he faints. But as the novel progresses, Bilbo prevails in the face of danger and adversity, justifying Gandalf’s early claim that there is more to the little hobbit than meets the eye.??????

Explanation:

7 0
2 years ago
Which option is used in emails to inform the recipient that they should exercise discretion in accordance with sharing the conte
Kay [80]
Priority levels hehe good luck!
5 0
3 years ago
The words, the computer is the future, has how many bits?
Nadusha1986 [10]

The words, the computer is the future, has 64 bits.Modern computer has

two types of processors which include:

  • 32 bit
  • 64 bit
<h3>Bits</h3>

This is referred to as the smallest unit of data which is used in a computer.

The 32 bit computer are the old types which have a smaller processor and is

relatively slow.

The 64 bit computer on the other hand are the modern types with large

processors and are relatively fast.

Read more about Computer here brainly.com/question/13380788

4 0
2 years ago
You have been tasked with ensuring that access to certain server managed resources is only available to client devices with TPM
elixir [45]

Answer:

Device Health Attestation Services

Explanation:

Based on the scenario being described it can be said that the Windows Server role that can be used to automate this check is known as Device Health Attestation Services. This is a role that allows the administrator to automatically check if a device has the required trustworthy BIOS, TPM, or boot software enabled, as well as Bitlocker encryption.

7 0
3 years ago
Write a cout statement so the variable sales is displayed with a precision of three decimal places, with the decimal point alway
Lilit [14]

Answer:

The statement is as follows:

cout <<fixed<< setprecision(3) <<sales;

Explanation:

Here, I assume that the variable has already been declared.

The syntax to use is:

cout<<fixed<<setprecision(n)<<variable-name;

In this case:

n = 3 --- i.e. to 3 decimal places

And the variable name is: sales

So, when implemented, the instruction is:

cout <<fixed<< setprecision(3) <<sales;

5 0
3 years ago
Other questions:
  • An application programming interface (API) is: Group of answer choices the code the application software needs in order to inter
    9·1 answer
  • What is microsoft access?
    14·1 answer
  • Before his job interview, Shabnam took the time to carefully wash and iron his best khaki pants and a button-down shirt. He even
    15·2 answers
  • Is a router on the local network that is used to deliver packets to a remote network?
    15·1 answer
  • Suppose you have one particular application that is trying to send data on the Internet but none of the data is making it to the
    15·2 answers
  • What is the primary responsibility of the federal reserve bank??
    11·1 answer
  • Which of these is not a valid form<br>layout in Microsoft Access?​
    11·1 answer
  • If a filesystem has a block size of 4096 bytes, this means that a file comprised of only one byte will still use 4096 bytes of s
    12·1 answer
  • Consider the following code:
    6·1 answer
  • The choice of database does not have any impact on the relevancy of search results?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!