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 C++ die roller program. We need you to write a program that will roll...
Write a C++ die roller program. We need you to write a program that will roll dice for them, but not just six-sided dice. Your program needs to be able to take an input in for form nDx or ndx where the d is the letter d or D. n may or not be present. If it is, it represents the number of dice. If not, assume it is a 1. x may or may not be present. If it...
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 problem I need to write a program which uses several threads (like 8...
C Programming language problem I need to write a program which uses several threads (like 8 threads for example) to sum up a number. The following program is using 1 thread but I need several threads to compile it. There was a hint saying that using multiple separate for loop and combining them will make a multi-threaded program. #include <stdio.h> #include <stdlib.h> #include <pthread.h> int sum; // this data is shared by the threads void *runner(void *param); // threads call...
in c++ you need to write a program that maintains the gradebook for a specific course....
in c++ you need to write a program that maintains the gradebook for a specific course. For each student registered in this course, the program keeps track of the student’s name, identification number (id), four exam grades, and final grade. The program performs several functionalities such as: enrolling a student in the course, dropping a student from the course, uploading student’s exam grades, displaying the grades of a specific student, displaying the grades of all students in the course, and...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT