COMM 205 Midterm Concordia University Trial Exam Solution, Exams of Communication

A trial exam solution for the comm 205 course at concordia university. It covers various programming concepts and constructs, such as variable declaration, numeric data types, conditional statements, loops, and event handling. Code fragments and multiple-choice questions to assess the student's understanding of these topics. The level of detail and the range of topics covered suggest that this document could be useful for university students enrolled in a programming or computer science course, particularly those taking the comm 205 course at concordia university. The document could serve as a study guide, lecture notes, or a practice exam to help students prepare for their midterm or final exams.

Typology: Exams

2024/2025

Available from 10/12/2024

studyroom
studyroom 🇺🇸

4.2

(5)

6.1K documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COMM 205 Midterm Concordia University trial exam solution
1. A company purchases notebook and tablet computers for its operations for set prices.
Notebooks cost $1,100 and the tablets cost $450. Write a code fragment that takes the
number of notebooks and tablets as inputs and computes the total cost. The inputs are
provided through the textboxes txtNotebooks and txtTablets. The output should be displayed
in lblTotal. (10 points)
double txtNotebooks, txtTablets, total;
txtNotebooks = 1100;
txtTablets 450;
lblTotal.Text = total.ToString();
2. decimal a = 10m;
double b = a;
The above code has a problem. To correct it you need to use a.
Try-catch
b.
TryParse()
c.
Math class
d.
Casting
3. Which of the following conditions checks if price is between $10 and $20 inclusively a.
price >= 10 || price <=20;
b.
price >= 10 && price <=20;
c.
20 >= price >= 10;
d.
10 <= price <= 20;
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download COMM 205 Midterm Concordia University Trial Exam Solution and more Exams Communication in PDF only on Docsity!

COMM 205 Midterm Concordia University trial exam solution

  1. A company purchases notebook and tablet computers for its operations for set prices. Notebooks cost $1,100 and the tablets cost $450. Write a code fragment that takes the number of notebooks and tablets as inputs and computes the total cost. The inputs are provided through the textboxes txtNotebooks and txtTablets. The output should be displayed in lblTotal. (10 points)

double txtNotebooks, txtTablets, total;

txtNotebooks = 1100; txtTablets 450;

lblTotal.Text = total.ToString();

  1. decimal a = 10m;

double b = a;

The above code has a problem. To correct it you need to usea. Try-catch

b. TryParse()

c. Math class

d. Casting

  1. Which of the following conditions checks if price is between $10 and $20 inclusivelya. price >= 10 || price <=20;

b. price >= 10 && price <=20;

c. 20 >= price >= 10;

d. 10 <= price <= 20;

If quantity has a value of 5, what is the value of discount after these statements are executed?

switch (quantity) {

case 1: case 2: case 3:

discount = 0; break;

discount = .1; default: discount = .2;

break;

break;

}

The switch statement has the following structure:

switch (test variable or expression) { case value_1: … case value_2: … } The valid types of test variable (or expression) include all of the following, except:

a. string

b. double

c. char

d. int

case "ca": country = "Canada"; break; case "fr": country = "France"; break; case "it": country = "Italy"; break; default: country = "No country found"; break; }

lblCountry.Text = country;

What is the term for a method that responds to events?a. event procedure

b. event exception

c. event wiring

d. event handler

The variable averageClassSize would be declared asa. Short

b. double

c. int

d. decimal

Customers who have at least 3 years of membership or spent at least $2000 at ourstore will get the star customer status. To implement such a rule we would use a. "if - else if"

b. ">=" and "||"

c. ">=" and "&&"

d. ">" and "&&"

Labels can be used ...a. for outputs

b. for inputs

c. both for inputs and outputs

d. only for labeling controls

What you may have to use when you want to convert between different numeric types ina statement a. Conversion

b. ToString()

c. TryParse()

d. Casting

What is wrong in the following code?

int sum = 0; int i;

for (int i = 10; i > 0; i --)

sum += i; i++;

a. i is changed within the body of the loop

b. Nothing

c. The starting values is 10

d. the decement i-- is used

To read exam results from a text file one would usea. switch

b. nested if

c. for

d. while

The following statement about a local variable is true: a. if a data item is needed only within a single method, it should be stored in a localvariable

b. a local variable is declared at the class level

c. a local variable is available in all methods within a form

d. a local variable exists in memory until the form is closed

In an organization when an employee is hired they get a set starting salary. Every second year the salary grows by 3%. Starting with the 11 years of service the salary willgrow by 2% every second year. Write a program fragment that takes number of years ofservice from a text box txtYears, and starting salary from txtStart, calculates salary for every second year (starting with year 1), and displays it in a list box lstSalary. Use data validation for the inputs to make sure they are numeric. (10 points)

The following statement about constants/variables is true, except: a. A variable may be assigned a value after it is declared

b. A constant must be assigned a value when it is declared

c. A constant cannot be assigned a value after it is declared

d. A variable must be assigned a value when it is declared

What is true abut the following loop

decimal counter = 1;

do{

sum += counter;

}

while(counter < 1) a. will never run

b. is an infinite loop

c. will not run since counter is not an int

d. will run one time

A variable taxRefund should be declared asa. Ulong

b. double

c. decimal

d. int