cosc 1436 hw

profilelaram14
ch5_classassignment3.uncomplete.docx

Class Assignment 3: Instructions

Name: ______________________________________ Date: _______________________________________________

1. Assign values to variable num1 to 100 and num2 to 20

a. Fill in the blanks with appropriate names

b. Rename this sheet to Your name_ Solution_Class Assignment 3 and submit it

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace ClassAssignment3

{

class Program

{

static void Main(string[] args)

{

int num1 = _________;

int num2 = _________;

int sum, product, difference, remainder, dividend;

sum = _______________ + ______________________;

product = ________________________ * ________________________;

if (_____________ > ____________________)

{

difference = ________________ - ____________________________;

dividend = _____________________ / ____________________;

remainder = ________________ %____________________________;

}

else

{

difference = ________________ - ____________________________;

dividend = ____________________ / ______________________;

remainder = ________________ % ____________________________;

}

Console.WriteLine(" The answers are sum = {0}, product = {1}, difference = {2}, dividend

= {3}, remainder = {4} ", -----------, ----------, -------, -------, -------);

}

}

}

2. How will you declare a float, string, char, bool, and decimal? Assign values to these data types as 1278.977, C#, c, and true.

3. There are two sentences in quotes “I am studying C# programming language” and “in COSC 1436” How will you concatenate them to print out the statement I am studying C# programming language in COSC 1436 ?

4. Write a code snippet that will ask the user to input two different numbers. Then take these two numbers and calculate their average. Write a print statement to display the average. Make sure the average value is down to its decimal value and not rounded off.

COSC 1436 Page 1