这是我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Exercise8
{
class Program
{
static void Main(string[] args)
{
//declare variables
int casesSold;
int costPerCase = 5; //Each case costs the Computer Club $5
int numBars = 12; //There are 12 candy bars in each case
double salePrice;
double forSGA = .9; //The Student Government Association (SGA) will collect 10% of the earnings that the Computer Club makes
string aCasesSold;
string aSalePrice;
//ask user for information
Console.WriteLine("Please enter how many cases were sold: ");
aCasesSold = Console.ReadLine();
Console.WriteLine("Please enter the sale price per candy bar: ");
aSalePrice = Console.ReadLine();
//Convert ints to strings so that they can be a part of the calculations
casesSold = int.Parse(aCasesSold);
salePrice = double.Parse(aSalePrice);
//calculate total cost for the Computer Club
public static double CalculateTotalCost(double totalCost, int costPerCase, int casesSold)
{
totalCost = costPerCase * casesSold;
return totalCost;
}
//calculate earnings for the Computer Club
public static double CalculateEarnings(int numBars, int casesSold, double earnings, double salePrice)
{
earnings = numBars * salePrice * casesSold;
return earnings;
}
//calculate proceeds
public static double CalculateProceeds(double proceeds, double forSGA, double earnings, double totalCost)
{
proceeds = (forSGA * earnings) - totalCost;
return proceeds;
}
//output proceeds to user
public static void Output()
{
Console.WriteLine("The proceeds for the Computer Club are: {0;C}", CalculateProceeds());
}
}
}
出于某种原因,我收到以下两个错误:
“} 预期”在结尾salePrice = double.Parse(aSalePrice);
和
“方法 'CalculateProceeds' 没有重载需要 0 个参数”
我不知道如何让控制台写我的结尾部分,你能帮我吗?我也不确定为什么 Visual Studio 认为我需要在末尾添加一个“}”salePrice = double.Parse(aSalePrice);
提前感谢您的所有帮助!