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
When a program terminates because a thrown exception is not handled, the program:
castortr0y [4]

Answer:

Option (e)

Explanation:

Option (e) is the answer. It indicates the exception thrown and displays it. It also indicates the place where the exception was thrown ( at what line of the code the exception was thrown )

Option (a) is false as the program which was terminated because of an exception which was not handled doesn't starts automatically.

Option (b) is false as it doesn't opens a dialogue box about running the program another time or anything. It just terminates because of the unhandled exception.

Option (c) is false as it doesn't saves all the output to a disk file called the "runStackTrace.txt".

Option (d) is false as it doesn't open a dialogue box. The program terminates because of the unhandled exception.

4 0
2 years ago
What is powerpoint in a presentation?
Hitman42 [59]
Powerpoint is slides to your subject, whatever your sub is you can go to google slides and make you powerpoint there. you might have make a email account im not sure.

hope this helped!
4 0
2 years ago
Read 2 more answers
It is a function that removes an existing file from the server.
kondaur [170]

Answer: A) remove()

Explanation:

 The remove() function removes an existing file from the server but it does not affect the existing directory and file. We can also ease and remove files in the file handling by using the remove() function. And it is built-in function that removes any type of the data from the function by taking values in the parameter whose values are equal with the passing value in the parameter.

7 0
3 years ago
Write a program that removes all spaces from the given input.
sasho [114]

Explanation:

#include<iostream>

#include<string.h>

using namespace std;

char *removestring(char str[80])

{

   int i,j,len;

   len = strlen(str);

   for( i = 0; i < len; i++)

   {

       if (str[i] == ' ')

       {

           for (j = i; j < len; j++)

               str[j] = str[j+1];

           len--;

       }

   }

   return str;

}

int main ()

{  

char  str[80];

   cout << "Enter a string : ";

   cin.getline(str, 80);

   strcpy(removestring(str), str);

   cout << "Resultant string : " << str;

   return 0;

}

In this program the input is obtained as an character array using getline(). Then it is passed to the user-defined function, then each character is analyzed and if space is found, then it is not copied.

C++ does not allow to return character array. So Character pointer is returned and the content is copied to the character array using "strcpy()". This is a built in function to copy pointer to array.

5 0
3 years ago
A programmer tests the procedure with various inputs and finds multiple cases where it does not produce the expected output. whi
AnnZ [28]

Answer:

longestWord(["frog", "seagull", "mermaid"])

longestWord(["crown", "diamond", "castle"])

Brainlist pls!

6 0
2 years ago
Other questions:
  • SELECT vendor_name, COUNT(*) AS number_of_invoices, MAX(invoice_total - payment_total - credit_total) AS balance_due FROM vendor
    15·1 answer
  • Consider ________ when designing for display on a mobile device. font size all of these contrast small screen size
    8·2 answers
  • Which of the following controls will provide an area in the form for the user to enter a name? a. button b. label c. text box d.
    8·1 answer
  • Dimensional arrays can be created using loops. 2 dimensional arrays can be created using:
    10·1 answer
  • A communication medium that carries a large amount of data at a fast speed is called
    6·1 answer
  • Which of the following is NOT part of the URL for an Internet web site?
    13·1 answer
  • The movie polar express was critically acclaimed due to the unbelievably lifelike movements of Tom Hanks character
    13·1 answer
  • How can you stay safe on the Internet? Check all that apply.
    8·2 answers
  • Which part of the brain controls the movement of muscles​
    6·1 answer
  • The PowerPoint view in which you can edit the slide master is called ______________.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!