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
The physical view of a database system refers to
tigry1 [53]

Answer:

C. how and where the data are physically arranged and stored.

Explanation:

The physical view as the name implies describes how and where the data are physically arranged in the database. This deals with the physical arrangement of data in the database. This user usually view the database in a logical way. e.g table. The physical arrangement is usually used by database specialists. There can be multiple logical view of a database but just a single view of the physical view.

8 0
3 years ago
How many conditions are needed in a while loop that should run until a user guesses the correct number or until they have made f
Sonja [21]
<h2>[] Hello! []</h2>

Answer:

2

Explanation:

MS Coding 1 A ED

---------------------------------------------------------------------------------------

  • I hope this helped
  • Brainilest appreciated!
7 0
3 years ago
PLEASE HELP WILL MARK AS BRAINLIEST
Katena32 [7]

Answer:

Manufacturing

Explanation:

Planning. Data plots on all things and future plans as in if how much is bought what prices of stock you will have. Person could improve by taking courses in business planning.

3 0
2 years ago
Mindy wants to create a new subdirectory at ~/2019projects/projectx/projectplans to start storing the initial project plans for
alexgriva [62]

Answer:

b. mkdir -p ~/2019projects/project/projectplans

Explanation:

mkdir command in Linux environment is used to create a new directory. This command is used to create a folder to store the information in organized manners.

-p is used to create a parent folder in the directory. If we want to start a new project or want to store information about some new topic we will create a new folder for that purpose. So, -p is used to create a new folder in directory.

In above mentioned case, this is the first project that Mindy started in 2019, so she should create a parent directory of 2019 to save all projects details that she worked in 2019. So she should use -p with mkdir command to make 2019 as a parent folder.

6 0
3 years ago
Write a C++ nested for loop code to print out the following onthe screen1 2 3 4 5 67 8 91 2 3 4 5 67 81 2 3 4 5 671 2 3 4 561 2
Mekhanik [1.2K]

Answer:

#include<iostream>

using namespace std;

//main function

int main(){

   

  //nested for loop

   for(int i=9;i>=1;i--){

       for(int j=1;j<=i;j++){

          cout<<j<<" ";  //display

       }

   }

   return 0;

}

Explanation:

Include the library iostream for using the input/output instruction in the c++ programming.

Create the main function and takes nested for loop. Nested for loop means, for loop inside the another for loop.

For every value of outside for loop, inside for loop execute.

we make outer for loop in decreasing format, means it start from 9 and goes to 1 and inside for loop make in increasing format, means loop start from 1 and it goes to that value which is provided by the outer loop.

and print the output for every cycle.

Lets dry run the code:

the outer loop starts from 9 and it checks the condition 9>=1, condition true. then the program moves to the inner loop which starts from 1 and goes to the 9.

first, it also checks the condition 1 <= 9, condition true and prints the number from 1 to 9.

then,  i is reduced by 1. it means i become 8.

then, the above process continues from 1 to 8 and so on...

the loop process will terminate if the outer loop terminate.

Finally, we get the output.

6 0
3 years ago
Other questions:
  • Explain what mistake Miranda made in the following scenario. Situation: Miranda suspects that there may be a problem with the ha
    13·2 answers
  • A communication medium which allows receivers to observe multiple cues, such as body language and tone of voice, and allows send
    15·1 answer
  • When virtualization is used and bare-metal solutions are implemented, what is the item that resides between the virtual machines
    12·2 answers
  • In vehicles equipped with ABS, the driver's foot must remain firmly on the _________ to activate the ABS.
    7·2 answers
  • A term to describe articles that can be displayed in their entirety,as opposed to abstract and references only
    11·1 answer
  • Select the correct answer. Cerise is explaining computer viruses to her students. What is the best way for her to explain a comp
    9·1 answer
  • FILL IN THE BLANK.
    10·1 answer
  • ______________ are used to store information that will be referenced and manipulated in a computer program. They label data with
    6·1 answer
  • Please help me please please
    14·2 answers
  • Most spyware programs are benign in that they do not perform malicious acts or steal data. group of answer choices true false
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!