Question

In: Computer Science

C# language Question: You need to write a program for students who receive bursaries in the...

C# language Question:

You need to write a program for students who receive bursaries in the department, managing the free hours they have to do.

For each recipient you store the recipient’s name and the number of hours outstanding.

All recipients start with 90 hours.

Implement class Recipients which has the private attributes Name and Hours.

In addition to the constructor, the class has the following methods:

public String getName()

// Returns the name of the recipient

public int getHours()

// Returns the hours outstanding

public void setHours(int P)

// Sets the hours outstanding In the application class (main method),

do the following

• Create three instances of Recipients, for Xola, David and Sandy

• Change their number hours outstanding, after each one worked the following time:

o Xola – 15 hours

o David – 10 hours

o Sandy – 20 hours

• Display the total number of hours due by the three recipients (add them up)

Solutions

Expert Solution

Here I have done code in C# which is as per your requirement, let me know in the comment section if you have any queries regarding the below code.

using System.IO;
using System;

class Recipients
{
    // private attributes
    private string Name;
    private int Hours;
    
    // public constructor
    public Recipients(string Name)
    {
        this.Name=Name;
        
        // Set Default Hours
        this.Hours=90;
    }
    
    // Returns the name of the recipient    
    public string getName()
    {
        return Name;
    }


    // Returns the hours outstanding
    public int getHours()
    {
        return Hours;
    }


    // Sets the hours outstanding
    public void setHours(int P)
    {
        Hours=Hours-P;
    }
    
    
    static void Main()
    {
        // Create three instances of Recipients
        Recipients first=new Recipients("Xola");
        Recipients second=new Recipients("David");
        Recipients third=new Recipients("Sandy");
        
        // Change their number hours outstanding
        first.setHours(15);
        second.setHours(10);
        third.setHours(20);
        
        // Print the total number of hours
        Console.Write(first.getHours()+second.getHours()+third.getHours());
    }
}

Output:


Related Solutions

*Need in C language also need full documentation/explanation of each line* Thank you! Write a program...
*Need in C language also need full documentation/explanation of each line* Thank you! Write a program that records high-score data from a simulated FIFA soccer game available online. The program will ask the user to enter the number of scores, create two dynamic arrays sized accordingly, ask the user to enter the indicated number of names and scores, and then print the names and scores sorted by score in descending order. The output from your program should look exactly like...
I need specific codes for this C program assignment. Thank you! C program question: Write a...
I need specific codes for this C program assignment. Thank you! C program question: Write a small C program connect.c that: 1. Initializes an array id of N elements with the value of the index of the array. 2. Reads from the keyboard or the command line a set of two integer numbers (p and q) until it encounters EOF or CTL - D 3. Given the two numbers, your program should connect them by going through the array and...
Write a program in C language 1- Define a struct for students with the aforementioned attributes,...
Write a program in C language 1- Define a struct for students with the aforementioned attributes, test it by populating one initialized struct variable with arbitrary input and take screenshots of the output. 2- For each student, struct add an array of number grades for a class the students are enrolled in such as S E 185. Then write functions which find the max, average, and minimum score for a specified assignment identified by a number, for example, Assignment 0...
Write a program that calculates the compound interest for an investment. (C++ coding language) If you...
Write a program that calculates the compound interest for an investment. (C++ coding language) If you deposit an amount of money P , the principal, at an interest rate r then the interest will compound over time. This means that the interest earned each period becomes part of the principal and the next time you get interest you earn interest on the interest. This is known as compounding. The equation for compound interest is ( r)n·t Pn=P0 1+n where P0...
Write the following in C language for Arduino: Write a program that turns on the LED...
Write the following in C language for Arduino: Write a program that turns on the LED at 25%, 50%, 75%, 100%, and then 0% brightness with a one second delay in between each change. Remember you are going to need to use a PWM pin and use the "analogWrite" command. The maximum value for our Arduino R3 boards is 255 and you need five steps (25%, 50%, 75%, 100%, and 0%) so you will need to determine the values for...
In this question, you are asked to write a simple java program to understand natural language....
In this question, you are asked to write a simple java program to understand natural language. The user will enter the input following the format: Name came to City, Country in Year. For example: Robin came to Montreal, Canada in 2009. Assume a perfect user will follow the exactly above formats for the inputs. Your program should be able to analyze the key words (Name, City, Country and Year) from the inputs and reorganize the outputs following format: Name stay...
Write a C Program that uses file handling operations of C language. The Program should perform...
Write a C Program that uses file handling operations of C language. The Program should perform following operations: 1. The program should accept student names and students’ assignment marks from the user. 2. Values accepted from the user should get saved in a .csv file (.csv files are “comma separated value” files, that can be opened with spreadsheet applications like MS-Excel and also with a normal text editor like Notepad). You should be able to open and view this file...
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user...
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user to enter the three examinations ( test 1, test 2, and test 3), homework, and final project grades then calculate and display the overall grade along with a message, using the selection structure (if/else). The message is based on the following criteria: “Excellent” if the overall grade is 90 or more. “Good” if the overall grade is between 80 and 90 ( not including...
C LANGUAGE ONLY Write a C program to count the frequency of each element in an...
C LANGUAGE ONLY Write a C program to count the frequency of each element in an array. Enter the number of elements to be stored in the array: 3 Input 3 elements of the array: element [0]: 25 element [1]: 12 element [2]: 43 Expected output: The frequency of all elements of an array: 25 occurs 1 times 12 occurs 1 times 3 occurs 1 times
In C programming language, write the program "3x3" in size, calculating the matrix "c = a...
In C programming language, write the program "3x3" in size, calculating the matrix "c = a * b" by reading the a and b matrices from the outside and writing on the screen?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT