Link to home
Start Free TrialLog in
Avatar of Student1
Student1

asked on

In the GetNet statement, I have an error saying, "Operator '*' cannot be applied to operands to type 'decimal' and 'double'.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Chapter5PA2
{
    class Program
    {
        static void Main(string[] args)
        {
            decimal Sales;
            double Ratio;
            decimal Net;

            Sales = GetSales();
            Ratio = GetProfit(Sales);
            Net = GetNet(Sales, Ratio);
            Convert.ToDouble(Sales);
            DisplayResults(Sales, Ratio, Net);
        }

       public static int GetSales()
        {
            int Sales;

            Console.WriteLine("    Sales Profit App");
            Console.WriteLine("Please enter the Sales amount: ");
            Sales = Int32.Parse(Console.ReadLine());

            return Sales;
        }

       public static double GetProfit(decimal Sales)
        {
            double ProfitRatio;
            if (Sales < 0)
                ProfitRatio = 0;
            else
                if (Sales < 1000)
                ProfitRatio = 0.03;
            else
               if (Sales > 1000.01m || Sales < 5000m)
                ProfitRatio = 0.035;
            else
                if (Sales > 5000.01m || Sales < 10000m)
                ProfitRatio = 0.040;
            else
                ProfitRatio = 0.045;

            return ProfitRatio;
       
        }

        private static decimal GetNet(decimal Sales, double Ratio)
        {
            decimal Net;
           
           Net = Sales * Ratio;

            return Net;
        }

        public static void DisplayResults(decimal Sales, double Ratio, decimal Net)
         {

            Console.WriteLine("\nSales Profit App");
            Console.WriteLine("Sales: " + "$"+ Sales);
            Console.WriteLine("Profit Ratio: {0:0.00%}" + Ratio + "%");
            Console.WriteLine("Net Proceeds: " + "$" + Net);
            Console.ReadKey();
        }
    }
}
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial