Question

Using Visual Studio 2017 Create This Program Using C# implement source code Program 2: Design (pseudocode)...


Using Visual Studio 2017 Create This Program Using C#

implement source code

Program 2: Design (pseudocode) and implement (source code) a program (name it BestDeal) to determine the best deal when buying a small box of apples vs. a large box of apples. The program asks the user to enter the weight and price of each box and then determines which box has a better value. The boxes may have the same value. Document your code and properly label the input prompts and the outputs as shown below.

Sample run 1:

Small box weight:     5 Pounds

Small box price:      10 Dollars

Large box weight:     12 Pounds

Large box price:      18 Dollars

Judgment:             The large box is a better deal

Sample run 2:

Small box weight:     5 Pounds

Small box price:      10 Dollars

Large box weight:     10 Pounds

Large box prices:     20 Dollars

Judgment:             Both boxes are of the same value

Sample run 3:

Small box weight:     5 Pounds

Small box price:      10 Dollars

Large box weight:     10 Pounds

Large box price:      28 Dollars

Judgment:             The smaller box is a better deal

0 0
Add a comment Improve this question Transcribed image text
Answer #1
using System;

public class BestDeal
{
    public static void Main(string[] args)
    {
        double smallWeight, smallPrice, largeWeight, largePrice;
        smallWeight = Convert.ToDouble(Console.ReadLine());
        smallPrice = Convert.ToDouble(Console.ReadLine());
        largeWeight = Convert.ToDouble(Console.ReadLine());
        largePrice = Convert.ToDouble(Console.ReadLine());
        Console.WriteLine("Small box weight:     " + smallWeight + " Pounds");
        Console.WriteLine("Small box price:      " + smallPrice + " Dollars");
        Console.WriteLine("Large box weight:     " + largeWeight + " Pounds");
        Console.WriteLine("Large box price:      " + largePrice + " Dollars");
        int cmp = (smallPrice / smallWeight).CompareTo(largePrice / largeWeight);
        if (cmp < 0)
        {
            Console.WriteLine("Judgment:             The smaller box is a better deal");
        }
        else if(cmp > 0)
        {
            Console.WriteLine("Judgment:             The large box is a better deal");
        }
        else
        {
            Console.WriteLine("Judgment:             Both boxes are of the same value");
        }
    }
}

Add a comment
Know the answer?
Add Answer to:
Using Visual Studio 2017 Create This Program Using C# implement source code Program 2: Design (pseudocode)...
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
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