C# Exercises

0 comments

1. Write a program that displays the name and address of your college.

You must match the format exactly:

Centennial College

Address: 941 Progress Ave, Scarborough, ON M1G 3T8

2. Write a program that prompts the user for his name and average monthly

visa bill. The program displays his name and his annual visa bill.

You must match the format exactly

Name: Justin Bieber

Annual Visa Bill: $12,000.00

Hint: annual bill = monthly bill * 12

3. Write a program that prompts the user for a letter. The program prints

the letter and the number equivalent. The number equivalent is obtained

by casting the char to an int.

YOU MUST READ IN THE INPUT AS A CHAR and you MUST do an explicit cast

You must match the format exactly:

Char: a

Number Equivalent: 97

4. Write a program that prompts the user for her home planet. Based on the

user’s input the program will display the following:

Input: earth

Message: earth. You are an Earthling and you have 10 fingers

Input: VENUS

Message: VENUS. You are a Venusian and you have 12 fingers

Input: Mars

Message: Mars. You are a Martian and you have 8 fingers

any other input

Message: I am sorry I don’t know of that planet

You may use either the ToUpper() or ToLower() methods

You MUST USE ONLY A SWITCH statement to solve this problem

[For full marks you need to accept all permutations of earth, venus

and mars, for example: “Earth”, “eARTh”, “VenuS”, “MARS”, “Mars”]

5. Write a program that prompts the user for her home planet. Based on the

user’s input the program will display the following:

Input: earth

Message: earth. You are an Earthling and you have 10 fingers

Input: VENUS

Message: VENUS. You are a Venusian and you have 12 fingers

Input: Mars

Message: Mars. You are a Martian and you have 8 fingers

Any other input

Message: I am sorry I don’t know of that planet

You may use either the ToUpper() or ToLower() methods

You MUST USE A NESTED IF statement to solve this problem [For full marks you need to accept all permutations of earth, venus and mars, for example: “Earth”, “eARTh”, “VenuS”, “MARS”, “Mars”]

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}