Click here to Skip to main content
15,889,877 members
Please Sign up or sign in to vote.
1.00/5 (7 votes)
See more:
Write a program that computes the amount of money the computer club will receive from proceeds of their granola bar sales project. Allow the user to enter the number of cases sold and the sale price per bar. Each case contains 12 bars; each case is purchased at $5.00 per case from a local vendor. The club is required to give the student government association 10% of their earnings. Display their proceeds formatted with currency. Write appropriate methods for your solution in c#?

What I have tried:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace @case
{
    class Program
    {
        static void Main(string[] args)
        {
            const double COST_PER_CASE = 5.00; 
            const double CASE_OF_BARS = 0; 
            const double NUMBER_OF_BARS = 12; 
            const double PRICE_OF_BARS = 0; 
            const double EARNINGS = 0.10; 
            string employeeName;
            int num1;
            double num2;
            double takeHomePay;
            Console.WriteLine("Enter employee name : ");
            employeeName = Console.ReadLine();
            Console.WriteLine("Input Number One: ");
            num1 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Enter number 2 ");
            num2 = Convert.ToDouble(Console.ReadLine());
            double bars = num1 * NUMBER_OF_BARS;
            double caseCost = num1 * COST_PER_CASE;
            double cost = bars * num2;
            takeHomePay = cost - caseCost;
            takeHomePay = takeHomePay * .90;
            Console.WriteLine("output : " + takeHomePay);
        }
    }
}
Posted
Updated 15-Mar-17 21:30pm
v2
Comments
Dave Kreskowiak 15-Mar-17 18:57pm    
...and...??? YOu forgot to ask a question.

No, we're not going to do your homework for you.
[no name] 15-Mar-17 19:10pm    
Just sticking a ? at the end of your homework assignment doesn't actually make it a question.
Patrice T 15-Mar-17 21:47pm    
And you have a question or a problem ?
Richard MacCutchan 16-Mar-17 5:05am    
The first thing you need to learn is bot to use the double type for financial issues. Use int or decimal.

Debugging is part of the process of programming.

Here is a video to show you how to use the tools available to you: Basic Debugging with Visual Studio 2010 - YouTube[^]

Watch the above video, then set a breakpoint in your code at the top and step through it to see exactly what it is doing... From there it should be obvious how to correct your homework.
 
Share this answer
 
Quote:
Problem it doesn't work well i need solutions for it ?

This is not informative.
Give an example:
- input that have the problem
- actual output
- wanted output
Use Improve question to update your question.

When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute, it is an incredible learning tool.

Debugger - Wikipedia, the free encyclopedia[^]
Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Basic Debugging with Visual Studio 2010 - YouTube[^]

The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900