Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your Assignment: This code is written in C#. Please correct this code so that it

ID: 3887107 • Letter: Y

Question

Your Assignment: This code is written in C#. Please correct this code so that it compiles and runs. This program contains 4 errors! Don't just correct the code but ALSO EXPLAIN WHAT YOU FIXED AND WHY!!

namespace DailyRate

{

class Program

{

static void Main(string[] args)

{

(new Program()).run();

}

void run()

{

double dailyRate = readDouble("Enter your daily rate: ");

int noOfDays = readInt("Enter the number of days: ");

writeFee(calculateFee(dailyRate, noOfDays));

}

private void writeFee(double p, int n)

{

Console.WriteLine("The consultant's fee is: {0}", p * 1.1);

}

private double calculateFee(double dailyRate, int noOfDays);

{

return dailyRate * noOfDays;

}

private double readInt(string p)

{

Console.Write(p);

string line = Console.ReadLine();

return int.Parse(line);

}

private double readDouble(int p)

{

Console.Write(p);

string line = Console.ReadLine();

return double.Parse(line);

}

}

}

Explanation / Answer

//To use Console you should use the statement using System;
using System;
namespace DailyRate {
class Program {
static void Main(string[] args) {
(new Program()).run();
}
void run() {
double dailyRate = readDouble("Enter your daily rate: ");
int noOfDays = readInt("Enter the number of days: ");
writeFee(calculateFee(dailyRate, noOfDays));
}
//writeFee should have only one argument, int is not necessary.
private void writeFee(double p) {
Console.WriteLine("The consultant's fee is: {0}", p * 1.1);
}
// private double calculateFee(double dailyRate, int noOfDays); remove the semicolon at the end
private double calculateFee(double dailyRate, int noOfDays) {
return dailyRate * noOfDays;
}
// return type of readInt should be int not double
private int readInt(string p) {
Console.Write(p);
string line = Console.ReadLine();
return int.Parse(line);
}
//readDouble argument type should be string not int
private double readDouble(string p) {
Console.Write(p);
string line = Console.ReadLine();
return double.Parse(line);
}
}
}

/*
sample output
Enter your daily rate: 3
Enter the number of days: 10
The consultant's fee is: 33
*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote