Selected Problems – CSC 102
on c#
Selected Problems – CSC 102
Arrays:
1. Use a one-dimensional array to solve the following problem: A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus 9% of $5000, or a total of $650. Write an application (using an array of counters) that determines how many of the salespeople earned salaries in each of the following ranges (assume that each salesperson's salary is truncated to an integer amount):
a. $200299
b. $300399
c. $400499
d. $500599
e. $600699
f. $700799
g. $800899
h. $900999
i. $1000 and over
2- Use a one-dimensional array to solve the following problem: Write an application that inputs five numbers, each of which is between 10 and 100, inclusive. As each number is read, display it only if it is not a duplicate of a number already read. Provide for the "worst case," in which all five numbers are different. Use the smallest possible array to solve this problem. Display the complete set of unique values input after the user inputs each new value.
2. Write an application that uses a foreach statement to sum the double values passed by the command-line arguments. [Hint: Use static method ToDouble of class Convert to convert a string to a double value.]
Methods:
1. A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Write an application that calculates and displays the parking charges for each customer who parked in the garage yesterday. You should enter the hours parked for each customer. The application should display the charge for the current customer and should calculate and display the running total of yesterday's receipts. The application should use method CalculateCharges to determine the charge for each customer.
2. Write method Multiple that determines, for a pair of integers, whether the second integer is a multiple of the first. The method should take two integer arguments and return true if the second is a multiple of the first and false otherwise. Incorporate this method into an application that inputs a series of pairs of integers (one pair at a time) and determines whether the second value in each pair is a multiple of the first.
3. Write method IsEven that uses the remainder operator (%) to determine whether an integer is even. The method should take an integer argument, and return true if the integer is even and false otherwise. Incorporate this method into an application that inputs a sequence of integers (one at a time) and determines whether each is even or odd.
4. What does the following method do?
// Parameter b must be a positive
// integer to prevent infinite recursion
public int Mystery( int a, int b )
{
if ( b == 1 )
return a;
else
return a + Mystery( a, b - 1 );
}
5. Find the error in the following recursive method, and explain how to correct it:
public int Sum( int n )
{
if ( n == 0 )
return 0;
else
return n + Sum( n );
}
Classes and objects:
1. Create a class called Employee that includes three pieces of information as instance variablesa first name (type string), a last name (type string) and a monthly salary (decimal). Your class should have a constructor that initializes the three instance variables. Provide a property with a get and set accessor for each instance variable. If the monthly salary is negative, the set accessor should leave the instance variable unchanged. Write a test application named EmployeeTest that demonstrates class Employee's capabilities. Create two Employee objects and display each object's yearly salary. Then give each Employee a 10% raise and display each Employee's yearly salary again.
2. Create a class called Date that includes three pieces of information as instance variablesa month (type int), a day (type int) and a year (type int). Your class should have a constructor that initializes the three instance variables and assumes that the values provided are correct. Provide a property with a get and set accessor for each instance variable. Provide a method DisplayDate that displays the month, day and year separated by forward slashes (/). Write a test application named DateTest that demonstrates class Date's capabilities.
3. Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variablesa part number (type string), a part description (type string), a quantity of the item being purchased (type int) and a price per item (decimal). Your class should have a constructor that initializes the four instance variables. Provide a property with a get and set accessor for each instance variable. In addition, provide a method named GetInvoiceAmount that calculates the invoice amount (i.e., multiplies the quantity by the price per item), then returns the amount as a decimal value. If the quantity is negative, it should be left unchanged. Similarly, if the price per item is negative, it should be left unchanged. Write a test application named InvoiceTest that demonstrates class Invoice's capabilities.
please help me i have examination sat
make me happy
i am waiting
our teacher don't have enough knowledge to explain