Question

Please help me with these two problems. Thank you. Part A Create a console-based application that...

Please help me with these two problems. Thank you.

Part A

Create a console-based application that prompts the user to enter the total price of the transaction as well as a sale or discount percentage, then returns the price of the transaction with the percentage discount applied.

You should create at least one method that accepts and returns data.

Part B

Create a console-based application named MealPrice that computes the price of a meal at a pirate-themed restaurant owned by programmers, called "Keep to the Code."

The Main() method should call the following methods:

  • A method to accept the number of sides the customer wants as input from the keyboard. This method returns the number of sides to the Main() method.
  • A method to accept as input and return the type of meal—‘k’ for a kids meal, ‘m’ for a meat entree, or ‘v’ for a vegetarian entree.
  • A method that accepts the number of sides and the meal type, then calculates and returns (rather than outputs) the cost of the meal as follows:
    • Kids' meals cost $5.00.
    • Meat entrees cost $10.00.
    • Vegetarian entrees cost $9.00.
    • The first side item is free, but each additional side costs $2.00.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Output will be like:

Code will be like:

using System;


namespace ConsoleApps
{
class Program
{
static void Main(string[] args)
{

//Part A
Console.WriteLine("Enter transaction amount");
int amount = Convert.ToInt16(Console.ReadLine());
Console.WriteLine("Enter discount percentage");
double percentage = Convert.ToInt16(Console.ReadLine());
double res= discountAmount(amount, percentage);
Console.WriteLine("The amount after discount is " + res);

//PartB

int sides=GetUserInput();
string userRes = typeOfMeal();

if(userRes=="k")
{
Console.WriteLine("Kids' meals cost $5.00.");
}
if (userRes == "m")
{
Console.WriteLine("Meat entrees cost $10.00 ");
}
if (userRes == "v")
{
Console.WriteLine("Vegetarian entrees cost $9.00");
}

if(sides>1)
{
Console.WriteLine("The sides cost is " + sides * 2);
}


Console.ReadLine();
}

static double discountAmount(int amnt, double percn)
{

return (amnt - amnt * (percn / 100));

}

static int GetUserInput()
{

Console.WriteLine("Enter number of sides");
int sides = Convert.ToInt16(Console.ReadLine());
return sides;

}

static string typeOfMeal()
{
Console.WriteLine("‘k’ for a kids meal, ‘m’ for a meat entree, or ‘v’ for a vegetarian entree");
string res=Console.ReadLine();
return res;
}

}
}

Please rate it if the above solution helps you in any way or if you have any concerns comment it, I will help you through again.

Add a comment
Know the answer?
Add Answer to:
Please help me with these two problems. Thank you. Part A Create a console-based application that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can you please help me with with problem. please follow all the specific insturctions, and try...

    Can you please help me with with problem. please follow all the specific insturctions, and try to make simple for a beginner in java. Write a class called Shape that contains instance data that represents the name and number of sides of the shape. Define a constructor to initialize these values. Include mutator(setter) methods – with the this reference – for the instance data, and a toString method that returns a the shape data. Create a static variable to keep...

  • please help me debug this Create a GUI for an application that lets the user calculate...

    please help me debug this Create a GUI for an application that lets the user calculate the hypotenuse of a right triangle. Use the Pythagorean Theorem to calculate the length of the third side. The Pythagorean Theorem states that the square of the hypotenuse of a right-triangle is equal to the sum of the squares of the opposite sides: alidate the user input so that the user must enter a double value for side A and B of the triangle....

  • Help with programming in C++ Phase 1 is complete, please help with phase 2. Thank you....

    Help with programming in C++ Phase 1 is complete, please help with phase 2. Thank you. Phase 1 You must design 3 algorithms, and provide both a flow chart and pseudo code for the algorithms.    Algorithm descriptions: Given an integer parameter named current_number and two constant global variables: const int MIN_NUMBER = 1; const int MAX_NUMBER = 8; Create an algorithm named forward, that will advance ONE value through a sequence of numbers 1, 2, 3 ... MAX_NUMBER. In...

  • In C++, Please help me compute the following flowchart exactly like this requirement: Use while loops...

    In C++, Please help me compute the following flowchart exactly like this requirement: Use while loops for the input validations required: number of employees(cannot be less than 1) and number of days any employee missed(cannot be a negative number, 0 is valid.) Each function needs a separate flowchart. The function charts are not connected to main with flowlines. main will have the usual start and end symbols. The other three functions should indicate the parameters, if any, in start; and...

  • Help Please on JAVA Project: Validating the input is where I need help. Thank you Requirements...

    Help Please on JAVA Project: Validating the input is where I need help. Thank you Requirements description: Assume you work part-time at a sandwich store. As the only employee who knows java programming, you help to write a sandwich ordering application for the store. The following is a brief requirement description with some sample output. 1. Selecting bread When the program starts, it first shows a list/menu of sandwich breads and their prices, then asks a user to select a...

  • Write a program in java. You are tasked with writing an application that will keep track...

    Write a program in java. You are tasked with writing an application that will keep track of Insurance Policies. Create a Policy class called InsurancePolicies.java that will model an insurance policy for a single person. Use the following guidelines to create the Policy class: • An insurance policy has the following attributes: o Policy Number o Provider Name o Policyholder’s First Name o Policyholder’s Last Name o Policyholder’s Age o Policyholder’s Smoking Status (will be “smoker” or “non-smoker”) o Policyholder’s...

  • In this lab, you will create a program to help travelers book flights and hotel stays that will b...

    In this lab, you will create a program to help travelers book flights and hotel stays that will behave like an online booking website. The description of the flights and hotel stays will be stored in two separate String arrays. In addition, two separate arrays of type double will be used to store the prices corresponding to each description. You will create the arrays and populate them with data at the beginning of your program. This is how the arrays...

  • Can someone please help me with this Python code? Thank you in advance, Zybooks keeps giving me e...

    Can someone please help me with this Python code? Thank you in advance, Zybooks keeps giving me errors. Thanks in advance!! This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class to contain a new attribute. (2 pts) item_description (string) - Set to "none" in default constructor Implement the following method for the ItemToPurchase class. print_item_description() - Prints item_description attribute for an ItemToPurchase object. Has an ItemToPurchase parameter. Ex. of...

  • please use python and provide run result, thank you! click on pic to make it bigger...

    please use python and provide run result, thank you! click on pic to make it bigger For this assignment you will have to investigate the use of the Python random library's random generator function, random.randrange(stop), randrange produces a random integer in the range of 0 to stop-1. You will need to import random at the top of your program. You can find this in the text or using the online resources given in the lectures A Slot Machine Simulation Understand...

  • Language is Java, any help is appreciated. Thank you! WHERE TO START FROM: import java.util.ArrayList; //PartTest.java...

    Language is Java, any help is appreciated. Thank you! WHERE TO START FROM: import java.util.ArrayList; //PartTest.java //package simple; public class PartTest { public static void main(String[] args) { ArrayList<ExpendablePart> system=new ArrayList<ExpendablePart>();   // creating Part Object Part part1 = new ExpendablePart("Last, First"); part1.setNumber("AX-34R"); part1.setNcage("MN34R"); part1.setNiin("ABCD-RF-WDE-KLJM"); // printing information System.out.println(part1.toString());       //Create a part2 object of class Part Part part2=new ConsumablePart("Widget, purple"); part2.setNumber("12345"); part2.setNcage("OU812"); part2.setNiin("1234-12-123-1234");    // printing information System.out.println(part2.toString());    //checking equality of two Part class objects if(part1.equals(part2)) System.out.println("part1 and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT