5
Reply

New to C# Need some help with this assignment

Nacoss Unibuja

Nacoss Unibuja

May 17 2012 9:14 AM
6k
Please help me answer the following questions and try to explain so that i can understand. Thanks

3.3 Write C# statements that accomplish each of the following tasks:

a) Display the message "Enter two numbers", using class MessageBox.

b) Assign the product of variables b and c to variable a.

c) State that a program performs a sample payroll calculation (i.e., use text that helps to document a program).

3.7 Write an application that displays the numbers 1 to 4 on the same line with each pair of adjacent numbers separated by one space. Write the program using the following methods:

a) Use one Console.Write statement.

b) Use four Console.Write statements.

3.8 Write an application that asks the user to enter two numbers obtains the two numbers from the user and prints the sum, product, difference and quotient of the two numbers.

3.9 Write an application that inputs from the user the radius of a circle and prints the circle's diameter, circumference and area. Use the following formulas (r is the radius): diameter = 2r, circumference= 2pr, area = pr2.

3.10 Write an application that displays in the console window a box, an oval, an arrow and a diamond, using asterisks (*) as follows:

 

3.11 Modify the program you created in Exercise 3.12 to display the shapes in a MessageBox dialog. Does the program display the shapes exactly as in Exercise 3.12?

3.12 What does the following code print?

Console.WriteLine( "*\n**\n***\n****\n*****" );

3.13 What does the following code print?

Console.Write( "*" );

Console.Write( "***" );

Console.WriteLine( "*****" );

Console.Write( "****" );

Console.WriteLine( "**" );

3.14 Write an application that reads in two integers and determines and prints whether the first is a multiple of the second. For example, if the user inputs 15 and 3, the first number is a multiple of the second. If the user inputs 2 and 4, the first number is not a multiple of the second. [Hint: Use the modulus operator.]

3.16 Write an application that inputs one number consisting of five digits from the user, separates the number into its individual digits and prints the digits separated from one another by three spaces each. For example, if the user types in the number 42339, the program should print:  4   2   3   3   9

[Hint: This exercise is possible with the techniques you learned in this chapter. You will need to use both division and modulus operations to "pick off" each digit.] For the purpose of this exercise, assume that the user enters the correct number of digits. What happens when you execute the program and type a number with more than five digits? What happens when you execute the program and type a number with fewer than five digits?

3.17 Using only the programming techniques you learned in this chapter, write an application that calculates the squares and cubes of the numbers from 0 to 10 and prints the resulting values in table format, as follows:

Number      square         cube

0                 0                 0

1                 1                 1

2                 4                 8

3                 9                 27

4                 16               64

5                 25               125

6                 36               216

7                 49               343

8                 64               512

9                 81               729

10               100             1000

 

[Note: This program does not require any input from the user.]

3.18 Write a program that reads a first name and a last name from the user as two separate inputs and concatenates the first name and last name, but separated by a space. Display the concatenated name at the command prompt.

3.19 Write a function that will add two arrays a and b together and store in array c.

3.20 Write a procedure that will use a MsgBox to display the grade of a student score using the following grading system:

     70 – 100            A

     60 - 69               B

     50 – 59              C

     45 - 49               D

     40 – 44               E

      0 - 39                 F

3.21 Write a function that accepts a number and returns the factorial

3.22 Write a validation code for a program used with ADO

3.23 Write a function that accepts an array of numbers and print them in reverse order.

3.24 Write a function that accepts any three numbers and computes the simple roots of a quadratic equation.

3.25 Write a function which accepts five numbers and prints the highest and the smallest of the numbers using a MsgBox function.



Answers (5)