Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You have decided to run a food truck with your friend that sells salads to the M

ID: 3885793 • Letter: Y

Question

You have decided to run a food truck with your friend that sells salads to the Mason community. For the truck to be successful, you must create an application that helps determine the total cost to purchase one salad. The cost of one salad is determined by the number of ingredients contained within it and the type of salad dressing it contains, if any. The only possible options for salad dressing are: No Dressing, Balsamic Vinaigrette, Bleu Cheese, or Thousand Island. Note that salad dressing does not count as an ingredient. Working with your friend, you decide upon the following rules to help you determine the cost for one salad Each salad has a base cost of $9.39 When the salad contains three ingredients or less, there is no additional charge When the salad contains more than three ingredients, but fewer than seven ingredients, there is an additional $2.85 charge When the salad contains seven or more ingredients, there is an additional $4.25 charge Selecting no salad dressing or Balsamic Vinaigrette adds no additional charge to the total salad cost, but selecting Bleu Cheese or Thousand Island adds an additional $1.29 to the salad cost All salads must be charged an additional 8.25% for sales tax of the total salad cost Create an application that will ask the user to provide the number of ingredients the salad will contain followed by the type of salad dressing the salad will contain, if any. Print a well-formatted report that displays the salad's base cost, the number of ingredients in the salad, the type of dressing selected (if any), the total cost of the salad before tax, the amount of the tax, and the grand total (including tax) While working with the program, if the user enters in any invalid values, the program must provide an error message, inform the user they should manually restart the program, and then immediately end. To Do (Check Blackboard for Due Dates): Programming Assignment 1: Solution Design 1) Show testing using the desk checking table method, to include test data, expected results, and a desk checking table. Make sure your desk checking considers multiple cases including both valid and invalid test data to prove your algorithm will work in all cases

Explanation / Answer


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner.*;
class salad_order
{
public static void main (String[] args)
{
int n, numb;
String salad;
double cost = 0.00, tot_cost = 0.00;
Scanner scan = new Scanner(System.in);
System.out.print(" Enter Number of Salad: ");
n = scan.nextInt();
System.out.print(" Enter the Number of Ingredients to be added in Salad: ");
numb = scan.nextInt();
System.out.print(" Enter the Salad Dressing: ");
salad = scan.nextLine();
  
if(numb <= 3)
cost = 9.39;
else if(numb > 3 && numb <= 7)
cost = (9.39 * n) + 2.85;
else
cost = (9.39 * n) + 4.25;   
System.out.printf(" Total Cost for Salad = $%.2f",cost);
  
double tc = cost;
if(salad == "no salad dressing" || salad == "no balsamic vinaigrette")
tot_cost = tc;
else if(salad == "bleu cheese" || salad == "thousand island")
tot_cost = tc + 1.29;
else
System.out.print(" Enter only in the list");
System.out.printf(" Total Cost for Salad Including Salad Dressing = $%.2f",tot_cost);
}
}
OUTPUT
Enter Number of Salad:
Enter the Number of Ingredients to be added in Salad:
Enter the Salad Dressing:
Total Cost for Salad = $49.80
Total Cost for Salad Including Salad Dressing = $51.09

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote