I have used BOLD where the errors occur. Could you please tell me how to fix the
ID: 3551795 • Letter: I
Question
I have used BOLD where the errors occur. Could you please tell me how to fix the code for c#?
// Program demonstrates method that can be called
// with one, two, or three arguments
// Tuition is $80 per credit
// Default district code is I.
// If student is in-district (code I), then there is no
// out-of-district fee, which is $300
// Default scholarship status is false.
// If student is on scholarship, tuition is free
using System;
class DebugEight3
{
static void Main()
{
Console.WriteLine("Tuition is {0}",CalculateTuition(15, 'I', true));
Console.WriteLine("Tuition is {0}",CalculateTuition(15, 'I', true));
Console.WriteLine("Tuition is {0}",CalculateTuition(15, 'I', true));
}
private static double CalculateTuition(double credits, char code = 'I', bool scholarship)
{
double tuition;
const double RATE = 80.00;
const double OUT_DISTRICT_FEE = 300.00;
tuition = credits * RATE;
if(code != 'I')
tuition += OUT_DISTRICT_FEE;
if(scholarship)
tuition = 0;
}
}
Explanation / Answer
// Program demonstrates method that can be called // with one, two, or three arguments // Tuition is $80 per credit // Default district code is I. // If student is in-district (code I), then there is no // out-of-district fee, which is $300 // Default scholarship status is false. // If student is on scholarship, tuition is free using System; class DebugEight3 { static void Main() { Console.WriteLine("Tuition is {0}",CalculateTuition(15, 'I', true)); Console.WriteLine("Tuition is {0}",CalculateTuition(15, 'I', true)); Console.WriteLine("Tuition is {0}",CalculateTuition(15, 'I', true)); } private static double CalculateTuition(double credits, char code, bool scholarship) // change char code='I' { double tuition; const double RATE = 80.00; const double OUT_DISTRICT_FEE = 300.00; tuition = credits * RATE; if(code != 'I') tuition += OUT_DISTRICT_FEE; if(scholarship) tuition = 0; return tuition; // return tution value, as return type is double. } }Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.