Question

Help In C# CHECKS: Program outputs score before and after bonus Method GiveBonus is overloaded Output:...

Help In C#

CHECKS:
Program outputs score before and after bonus

Method GiveBonus is overloaded

Output:
It has to look exactly like that

Output

Scores was 82.Now it is 5.
Grade was B Now it is +

---------------------------------------------------------------------

DebugEight2.cs has syntax and/or logical errors. Determine the problem(s), and fix the program.

CODE:

// Overloaded method gives bonus points
// whether grade is a number or letter

using static System.Console;

class DebugEight2
{
static void Main()
{
int numericScore = 82;
string letterScore = "B";
WriteLine("Score was {0}.", numericScore);
GiveBonus(ref numericScore);
WriteLine("Now it is {0}.", numericScore);
WriteLine("Grade was {0}.", letterScore);
GiveBonus(ref letterScore);
WriteLine("Now it is {0}.", letterScore);
}

public static void GiveBonus(ref int testScore)
{
const int BONUS = 5;
testScore += BONUS;
}

public static void GiveBonus(ref string letterScore)
{
const string BONUS = "+";
letterScore += BONUS;
}
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The answer to this question is as follows:

The code is as follows:

using static System.Console;

class DebugEight2
{
static void Main()
{
int numericScore = 82;
string letterScore = "B";
Write("Score was {0}.", numericScore);
GiveBonus(ref numericScore);
Write("Now it is {0}.\n", numericScore);
Write("Grade was {0}.", letterScore);
GiveBonus(ref letterScore);
WriteLine("Now it is {0}.", letterScore);
}

public static void GiveBonus(ref int numericScore)
{
const int BONUS = 5;
numericScore+= BONUS;
}

public static void GiveBonus(ref string letterScore)
{
const string BONUS = "+";
letterScore+= BONUS;
}
}

The input and ouput are provided below:

V Execute Mode, Version, Inputs & Arguments mono 6.0.0 Interactive Stdin Inputs Command Line Arguments → Execute Result CPU Time: 0.02 sec(s), Memory: 21104 kilobyte(s) compiled and executed in 1.067 sec(s) Score was 82.Now it is 5. Grade was B. Now it is +.

Add a comment
Know the answer?
Add Answer to:
Help In C# CHECKS: Program outputs score before and after bonus Method GiveBonus is overloaded Output:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C# Programming: DebugNine2 The provided file has syntax and/or logical errors. Determine the problem(s) and fix...

    C# Programming: DebugNine2 The provided file has syntax and/or logical errors. Determine the problem(s) and fix the program. +DebugNine2.cs Instructions Build Output The provided file has syntax and/or logical errors. Determine the problem(s) and fix the program. 1/ Creates a Breakfast class 2 // and instantiates an object 3// Displays Breakfast special information 4 using static System.Console; Conpilation fatled: 2 error(s), 8 warnings DebugNine2.cs(9,61): error C$1810: Newline in constant DebugNine2.cs (11,6): error CS1525: Unexpected synbol "Writeltne class DebugNine2 7static void...

  • The following file has syntax and/or logical errors. In each case, determine the problem, and fix...

    The following file has syntax and/or logical errors. In each case, determine the problem, and fix the program. using System; using static System.Console; using System.IO; class DebugFourteen1 { static void Main() { string fileName; string directory; string path; string files; int x; Write("Enter a directory: "); directory = ReadLine(); if(Directory.Exists(Directory)) { files = Directory.GetFiles(directory); if(files.Length = 0) WriteLine("There are no files in " + directory); else { WriteLine(directory + " contains the following files"); for(x = 0; x <= files.Length;...

  • The following individual two programs are using while loop in order to print a specific output:...

    The following individual two programs are using while loop in order to print a specific output: The outputs of the first program are: 10 9 8 5 4 The outputs of the second program are: 123456789 Using the Table 3.1 below, allocate the error(s) of each line of two programs and type of error: The first program: public Main { public static void main(String args[]){ int i=10 while(i>4){ System.out.print(i); i++; } } } The second program:   public class Main   {...

  • The following individual two programs are using while loop in order to print a specific output:...

    The following individual two programs are using while loop in order to print a specific output: The outputs of the first program are: 10 9 8 5 4 The outputs of the second program are: 123456789 Using the Table 3.1 below, allocate the error(s) of each line of two programs and type of error: The first program: public Main { public static void main(String args[]){ int i=10 while(i>4){ System.out.print(i); i++; } } } The second program:   public class Main   {...

  • This C# program prints out a corresponding letter grade for a given mark. It uses a...

    This C# program prints out a corresponding letter grade for a given mark. It uses a method (called MarktoGrade) to determine the letter grade. MarktoGrade takes one integer call by value formal parameter (called mark) and returns a char value that is the letter grade. All of the input and output (except an error message) is done in Main. There is one syntax error in this program that you will need to fix before it will compile (the error is...

  • For the following C# program: Let’s add one more user defined method to the program. This...

    For the following C# program: Let’s add one more user defined method to the program. This method, called ReverseDump is to output the values in the array in revere order (please note that you are NOT to use the Array.Reverse method from the Array class). The approach is quite simple: your ReverseDump method will look very similar to the Dump method with the exception that the for loop will count backwards from num 1 to 0 . The method header...

  • In Chapter 11, you created the most recent version of the GreenvilleRevenue program, which prompts the...

    In Chapter 11, you created the most recent version of the GreenvilleRevenue program, which prompts the user for contestant data for this year’s Greenville Idol competition. Now, save all the entered data to a Greenville.ser file that is closed when data entry is complete and then reopened and read in, allowing the user to view lists of contestants with requested talent types. The program should output the name of the contestant, the talent, and the fee. using System; using static...

  • JAVA HELP: Directions Write a program that will create an array of random numbers and output...

    JAVA HELP: Directions Write a program that will create an array of random numbers and output the values. Then output the values in the array backwards. Here is my code, I am having a problem with the second method. import java.util.Scanner; import java.util.Random; public class ArrayBackwards { public static void main(String[] args) { genrate(); print(); } public static void generate() { Scanner scanner = new Scanner(System.in);    System.out.println("Seed:"); int seed = scanner.nextInt();    System.out.println("Length"); int length = scanner.nextInt(); Random random...

  • Use a C# In previous chapters, you have created programs for the Greenville Idol competition. Now...

    Use a C# In previous chapters, you have created programs for the Greenville Idol competition. Now create a Contestant class with the following characteristics: The Contestant class contains public static arrays that hold talent codes and descriptions. Recall that the talent categories are Singing, Dancing, Musical instrument, and Other. Name these fields talentCodes and talentStrings respectively. The class contains an auto-implemented property Name that holds a contestant’s name. The class contains fields for a talent code (talentCode) and description (talent)....

  • Please Help in C#, Let me know if you have any questions. Please make sure the...

    Please Help in C#, Let me know if you have any questions. Please make sure the program passes the checks Checks: Question: My code works, it just this needs to be added there which I don't know what I need to do.    In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format the output...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT