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
STatiana [176]
2 years ago
6

The Gas-N-Clean Service Station sells gasoline and has a car wash. Fees for the car wash are $1.25 with a gasoline purchase of $

10.00 or more and $3.00 otherwise. Three kinds of gasoline are available: regular at $2.89, plus at $3.09, and super at $3.39 per gallon. User Request:
Write a program that prints a statement for a customer. Analysis:
Input consists of number of gallons purchased (R, P, S, or N for no purchase), and car wash desired (Y or N). Gasoline price should be program defined constant. Sample output for these data is
Enter number of gallons and press 9.7
Enter gas type (R, P, S, or N) and press R
Enter Y or N for car wash and press Y
**************************************
* *
* *
* Gas-N-Clean Service Station *
* *
* March 2, 2004 *
* * ************************************** Amount Gasoline purchases 9.7 Gallons Price pre gallons $ 2.89 Total gasoline cost $ 28.03 Car wash cost $ 1.25 Total due $ 29.28 Thank you for stopping Pleas come again Remember to buckle up and drive safely
Computers and Technology
1 answer:
Xelga [282]2 years ago
4 0

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

              //print the header

              System.out.println("**************************************");

              System.out.println("*                                    *");

              System.out.println("*                                    *");

              System.out.println("*   Gas-N-Clean Service Station      *");

              System.out.println("*                                    *");

              System.out.println("*   March 2, 2004                    *");

              System.out.println("*                                    *");

              System.out.println("**************************************");

 

               //set the constant values for gasoline

               final double REGULAR_GASOLINE = 2.89;

               final double PLUS_GASOLINE = 3.09;

               final double SUPER_GASOLINE = 3.39;

 

              // initialize the variables as 0

              double gasolinePrice = 0, gasolineCost = 0, carWashCost = 0, totalCost = 0;

 

               Scanner input = new Scanner(System.in);

 

               //ask the user to enter the gallons, gas type and car wash choice

               System.out.print("Enter number of gallons ");

               double gasolinePurchase = input.nextDouble();

               System.out.print("Enter gas type (R, P, S, or N) ");

               char gasType = input.next().charAt(0);

               System.out.print("Enter Y or N for car wash ");

               char carWashChoice = input.next().charAt(0);

               //check the gas type. Depending on the choice set the gasolinePrice from the corresponding constant value

              if(gasType == 'R')

                  gasolinePrice = REGULAR_GASOLINE;

              else if(gasType == 'P')

                  gasolinePrice = PLUS_GASOLINE;

              else if(gasType == 'S')

                  gasolinePrice = SUPER_GASOLINE;

 

                //calculate the gasolineCost

                gasolineCost = gasolinePurchase * gasolinePrice;

 

               //check the carWashChoice. If it is yes and gasolineCost is greater than 10, set the carWashCost as 1.25. Otherwise, set the carWashCost as 3.00

               if(carWashChoice == 'Y'){    

                   if(gasolineCost >= 10)

                       carWashCost = 1.25;

                   else

                       carWashCost = 3.00;

               }

              //calculate the total cost, add gasolineCost and carWashCost

              totalCost = gasolineCost + carWashCost;

 

               //print the values in required format

              System.out.println("Amount Gasoline purchases " + gasolinePurchase);

              System.out.println("Gallons Price per gallons $ " + gasolinePrice);

              System.out.printf("Total gasoline cost $ %.2f\n", gasolineCost);

              System.out.println("Car wash cost $ " + carWashCost);

              System.out.printf("Total due $ %.2f\n", totalCost);

               System.out.println("Thank you for stopping\nPlease come again \nRemember to buckle up and drive safely");

}  

}

Explanation:

*The code is in Java.

Please see the comments in the code for explanation

You might be interested in
3. When code tracing, why is it important to iteratively test parts of the program?
GenaCL600 [577]

Answer:

A. To isolate errors in the outcomes of code.

<em>Hope this helps! ^-^</em>

<em>-Isa</em>

7 0
3 years ago
What is the difference between front-end and back-end?
IgorLugansk [536]

Front-end the part with which the user interacts.

usually people who write this are called layout designers what languages ​​are used (Html, css, js)

Beck-end The northern part is the structure of the site due to which it works, this includes the DBMS, logic, etc. which languages ​​will be used(python, php, java)

People who can do both are called: full stack developr

3 0
2 years ago
When you tell an acquaintance your telephone number, you do not recite the digits one by one at a constant rate, as in "3, 3, 7,
yKpoI14uk [10]

Answer:

chunking and short-term is the correct answer of this question.

Explanation:

chunking is a strategy to enhance a short-term memory.

Chunking is an method used to separate larger numbers that can not be psychologically separated.Chunking is the grouping of words in one sentence into short, important phrases. A chunk is the material segment that is used in many graphical formats, such as PNG etc.

Short-term memory is the knowledge a person is considering or is conscious of. This is also called healthy or main memory.

3 0
3 years ago
Direct messages are the only private forms of communication on Twitter. True False
Sunny_sXe [5.5K]
True but ill keep typing so it meets twenty charecters                                              

7 0
3 years ago
5-11) (Find the Smallest Value) Write an application that finds the smallest of several integers. Write a program which first as
Elanso [62]

Answer:

import java.util.Arrays;

import java.util.Scanner;

public class num4 {

   public static void main(String[] args) {

   Scanner in = new Scanner(System.in);

       System.out.println("How many numbers? ");

       int n = in.nextInt();

       int []intArray = new int[n];

       //Entering the values

       for(int i=0; i<intArray.length;i++){

           System.out.println("Enter the numbers");

           intArray[i]=in.nextInt();

       }

       System.out.println(Arrays.toString(intArray));

       int min =intArray[0];

       for(int i =0; i<intArray.length; i++){

           if(min>intArray[i]){

               min = intArray[i];

           }

       }

       System.out.println("The Minimum of the numbers is "+min);

   }

}

Explanation:

  • Using Java programming language
  • Prompt the user for the number of values
  • Using Scanner class receive and store in a variable
  • Create an array of size n
  • Using an for loop continuously ask the user to enter the integers
  • Print the array of integers
  • Using another for loop with an if statement, find the smallest element in the array of numbers
  • Output the the smallest number
8 0
3 years ago
Other questions:
  • Periodically adding, changing and deleting file records is called file. A) Updating B) Upgrading C) Restructuring D) Renewing E)
    10·2 answers
  • Using social media and sending a blast are examples of
    13·1 answer
  • Which device on a network performs network address translation?
    8·1 answer
  • Drugs of addiction act upon a portion of the Brain called the lambic system ? True or false.
    7·1 answer
  • You work for a company that is growing. Originally, all the users in all departments had access to all the data in the database.
    6·2 answers
  • Select the statements that are true regarding the future of technology. Select 2 options.
    12·1 answer
  • What type of engineer is interested in designing, developing, and building different machines, devices, and tools? A.aerospace
    8·2 answers
  • Please help meeee , you will get 20 points
    9·2 answers
  • Task #3 Debugging a Java Program
    14·1 answer
  • Help me with this two questions please
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!