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
All of the following are tips for a great presentation except
Burka [1]

Answer: B. Use a variety of animations on most slides to keep your audiences attention.

Explanation:

While animations can serve as a tool to make your presentation more engaging, too many of them can end up being a distraction and can end up potentially frustrating the audience.

5 0
3 years ago
Read 2 more answers
Which of the following was a major economic concern in the mid to late 1970
Charra [1.4K]
Without knowing any definite answer I would probably guess the military spending in Vietnam
7 0
3 years ago
Read 2 more answers
Java Array question.
kodGreya [7K]

Answer:

3) 3 44 44

Explanation:

Given data

int [] val = { 3, 10, 44 };

The total number of parameters of given array are 3, so total length of array is also 3.

The indexing of array starts with '0', Therefore the <u>indexes</u> of array with length zero are: {0,1,2}

The value of array at index 0 is = 3

similarly

value at index 1 = 10

value at index 2 = 44

Here, Int i = 1 is storing the value '1' in integer variable i.

In addition to that, any value of index 'i' of an array is selected using array[i].

Therefore,

val[i] is selecting the value of array located at index '1' because i = 1.

val[i] = val[1] = 10

val[i+1] is selecting the value of array located at index 'i+1' that is (1+1) =2

val[i+1] = val[2] = 44

Finally,

val[i] = val[i + 1]; is copying the value placed at index 2 (44) to value placed at index 1 (10). Hence, the output would be {3 44 44}. So 3rd option is correct.

 

3 0
3 years ago
What is a resume?A collection of all your professional and artistic works.A letter which explains why you want a particular job.
mars1129 [50]

Answer:

a 1-2 page document that demonstrates why you are qualified for a job by summarizing your skills, education, and experience.

7 0
3 years ago
Binary tree algorithm?
Mrac [35]
My answer is attached.....

good luck.

5 0
3 years ago
Other questions:
  • 2. What is the layout of the modern keyboard known as?
    13·1 answer
  • (1) In Tamara's science class, the students are learning Which sentence shows an action that is extrinsically
    7·1 answer
  • What is the relationship between a method and a function
    11·2 answers
  • There are three types of value for money. Which of the following is not a method of value?
    14·1 answer
  • Write another function to convert a value to its word equivalent leveraging the following tuple - o Number = (‘One’, ‘Two’, … ‘N
    10·1 answer
  • Write a function called show_info that takes a name, a home city, and a home state (a total of 3 arguments) and returns a full s
    12·1 answer
  • Write a program that computes the minimum, maximum, average and standard deviation of the population over time for a borough (en
    6·1 answer
  • The 10 and 2 o'clock hand position on the steering wheel is no longer recommended because _____.
    13·1 answer
  • PLEASE HELP I HAVE A TEST RIGHT NOW!!!
    13·1 answer
  • How will you keep the buzz going post-hackathon?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!