Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Standard view
Full view
of .
0 of .
Results for:
P. 1
C Sharp Exercises

# C Sharp Exercises

Ratings:

5.0

(3)
|Views: 5,820|Likes:

### Availability:

See more
See less

01/07/2013

pdf

text

original

1.Write a program that randomly fills a 3 by 4 by 6 array, then prints the largest andsmallest values in the array.2.Sales tax in New York City is 8.25%. Write a program that accepts a price on thecommand line and prints out the appropriate tax and total purchase price.3.Modify the sales tax program to accept an arbitrary number of prices, total them,calculate the sales tax and print the total amount.4.Write a program that reads two numbers from the command line, the number of hours worked by an employee and their base pay rate. Then output the total paydue.5.Modify the previous program to meet the Dept. of Labor's requirement for timeand a half pay for hours over forty worked in a given week.6.Add warning messages to the payroll program if the pay rate is less than theminimum wage (\$4.35 an hour as of mid-1996) or if the employee worked morethan the number of hours in a week.7.There are exactly 2.54 centimeters to an inch. Write a program that takes anumber of inches from the command line and converts it to centimeters.8.Write the inverse program that reads a number of centimeters from the commandline and converts it to inches.9.There are 454 grams in a pound and 1000 grams in a kilogram. Write programsthat convert pounds to kilograms and kilograms to pounds. Read the number to beconverted from the command line. Can you make this one program instead of two?10.The equivalent resistance of resistors connected in series is calculated by addingthe resistances of the individual resistors. Write a program that accepts a series of resistances from the command line and outputs the equivalent resistance.11.The formula for resistors connected in parallel is a little more complex. Given tworesistors with resistances R1 and R2 connected in parallel the equivalentresistance is given by the inverse of the sum of the inverses, i.e. * If there aremore than two resistors you continue to invert the sum of their inverses; e.g. for four resistors you have: * Write a program that calculates the resistance of a agroup of resistors arranged in parallel.12.Write a ForexDeal class in CSharp with the following characteristics:Data members:PortfolioDPortfolioManager CustomerD)BuyiSellBuyingCurrencySellingCurrencyAmountOperations:Appropriate constructorsPromsRequestCancelRequest

13.Write a class with a set of static methods to perform foreign exchangeconversions. For e2, it could do conversion from INR to USID(Indian Rupee to US Dollar).14.Write a program to print the various data types in CSharp language.Also include a non-String object reference in the list.15.Write a program to parse a bunch of user-specified command lineoptions for running a program.16.Write programs to test some fundamental language elements likeconditionals, loops, labels etc.17.Write a class Person with FirstName and LastName as data members.Override the toString() method to return the full name of the person.Define constructors to take appropriate parameters. This class does nothave a default constructor. Use the this() to invoke other constructors.18.Write a class SurveyOperator derived from Person. This class has thefollowing additional members:Data members: NumberOfCalls NumberOfSuccessfulCallsTotalTimeAvailableOperations:GetNumberOfCallsGetNumber-OfSuccessfulCallsSetAvailableMakeCallDefine appropriate constructors for this class. Remember the fact that the base class Person does not have a default constructor and needs an explicitinvocation using super().19.Write a program to study the constructor calling sequencein case of inheritance.20.Write a program to print the list of system properties to the console.21.Write a program to copy elements of one array into another 22.Write a program to reverse a string and test it.23.Write a program to count the number of tokens, given a string anda separator.24.Use the numeric wrapper class to do conversion between the typesand also to convert strings to primitive data types.25.Write a program to use some the APIs provided by the Math class.26.Write a program that takes a filename and reads the contents of the file by lines. Also catch the required exceptions.

27.Write an exception class NotAvailableException that just contains acustom message printed.28.Write a program that writes data into file. The data to be written are theCSharp data types and not just bytes.29.Write a program to count the numbers of characters entered through stdin.The program exits upon entering Ctrl+Z.30.Accept a filename. Write a program to print the properties of the file31.Write a program to accept a filename and print the contents of the filealong with the line numbers. It could be the source code itself.32.We have two variables,
int a=-7;
ja
int i=8;
Find out the values of i and a after each assignment. Each line is to be processed distinct, a) does not affect to latter ones and so on... Nothing else is done between definition and assignment.
a) a = ++i;b) a = i++;c) a = --i;