Describe two types of loops that can be used to print

Assignment Help DOT NET Programming
Reference no: EM131119666

1. Set a variable to a value with the symbol _____, and test equality with _____.

=, =

==, ==

=, ==

==, =

2. In the context of object-oriented programming, the Solution Explorer window _____.

exposes the properties of the control

shows the physical components of the program

lists the events associated with a control

lists the controls on the form

3. C# comments are represented by which characters?

// and /* */

:: and //

// and >>

>

4. Your C# program needs to store a single alphanumeric character the user will enter. When your program starts, the default setting for that character should be the letter A. You implement this functionality by writing _____.

char myVar = A;

char myVar = ‘A';

char myVar(‘A');

char myVar(A);

5. What will be the output of this statement?

Console.WriteLine("\"to be or not to be\"");

"to be or not to be"

\"to be or not to be\"

\ to be or not to be \

to be or not to be

6. Before you start writing a program, it's important to first thoroughly _____.

analyze the problem

design the solution

specify the problem

All of the above

7. C# decision structures include _____ and _____.

IF, IF/ELSE

IF, FOR

FOR, FOREACH

FOR, WHILE

8. The following C# code _____ compile; however, it contains a _____ error.

int x = 15, y = 10;

if (x < y);

Console.WriteLine("x is less than y");

will, compiler

will, logical

will not, compiler

will not, logical

9. In this code, the variable _____ is a counter and the variable _____ is an accumulator.

double sum = 0, height = 2.0, stop =10, max = 50;

int track = 0, num = 0;

while (num <= stop)

{

sum = sum + height * num;

if (sum <= max)

track++;

num++;

}

num, track

sum, track

track, sum

height, stop

10. What output will this set of statements produce?

int a = 10;

while (a <= 10)

{

Console.Write("{0}\t", a);

a--;

}

Console.Write("{0}\t", a);

An infinite loop

An exception

10

10 10

Part 2

1. Because Main() and MyFunction() store counter in _____, the output of this code will be _____.

static void Main()

{

int counter = 8;

Console.Write("{0} ", counter);

counter++;

MyFunction(ref counter);

counter++;

Console.Write("{0} ", counter);

Console.Read();

}

public static void MyFunction(ref int counter)

{

Console.Write("{0} ", counter);

counter++;

}

different memory locations, 8 9 10

the same memory location, 8 9 10

different memory locations, 8 9 11

the same memory location, 8 9 11

2. Which is a valid name for a method or function?

mthd1

1_mthd

MyMthd@1

1mthd

3. Which is a correct heading for a method that returns the difference between two given doubles?

public static void CalcDiff(double price1, double price2);

public static double CalcDiff(double price1 , anotherPrice)

public static double CalcDiff(double price1 , double price2);

public static CalcDiff(double price1, double price2);

4. A(n) _____ is a notification from the _____ that an action has occurred, such as a mouse click or a key press.

event, GUI application

console application, operating system

GUI application, event

event, operating system

5. Which of the following statements will retrieve the selected item of comboBoxEntrees and place it in a myString variable called "myStr"?

myString myStr = comboBoxEntrees.SelectedItem;

myString myStr = comboBoxEntrees.Selection();

myString myStr = comboBoxEntrees.Text;

myString myStr = comboBoxEntrees.getText();

6. Because a _____ inherits members from the _____ class, it has the methods Show() and Hide().

Button, Control

Form, Control

RadioButton, ComboBox

TextBox, Form

7. Given the following declaration, what is/are the value(s) of inches[1,1]?

double[,] inches = { {2.25, 3.25, 4.5, 7.25},

{3.75, 4.75, 3.5, 3.75} };

2.25

2.25 3.75

3.25 4.75

4.75

8. An array is a list of data items that _____.

are all integers

are not indexed

have different names

share the same data type

9. To delete a specified number of characters from a String, use its _____ method.

Delete();

Concat();

Insert();

Remove();

10. To print out the time a file called "timeSheet.txt" was created, write _____.

Console.WriteLine(File.GetCreationTime("timeSheet.txt"));

Console.WriteLine(GetFileInfo("timeSheet.txt");

Console.WriteLine(GetCreationTime("timeSheet.txt");

Console.WriteLine(File.FileInfo("timeSheet.txt");

11. A _____ represents a chunk of data and enables the programmer to work with a sequence of bytes.

Directory

File

Stream

TextFile

12. In the following code, the statement "StudentData.Close()" _____.

try

{

StreamWriter StudentData = new StreamWriter("Dossier.txt",true);

for (int i = 0; i < 10; i++)

StudentData.WriteLine("Student[{0}]: ", i);

StudentData.Close();

}

writes 10 lines to "Dossier.txt"

keeps the StreamWriter object "StudentData" open

writes a final new line to "Dossier.txt"

Part 3

1. Show the source code for a C# console application called "Downpayment" to display the 20% down payment one would make on a $250,000 house. (Note that the down payment would be .20 times the value of the house.)

Declare and initialize appropriate variables for down payment and house value.

Include at least three descriptive comments.

State what your program displays when it runs.

State how you would use the debugger to check the values of your variables as your program runs.

2. Describe two types of loops that can be used to print every third integer from 0 to 300 (i.e., 0, 3, 6, 9, etc.), each on its own line. Which would be a better choice and why? Write the code using that type of loop.

3. Briefly describe how parameter passing by-value and by-reference are accomplished in memory. Write statement 1 to call method A below. Write statement 2 to call method B. Which method uses pass by-value? Which method uses pass by-reference?

static void Main()

{

int balance = 15000;

//statement 1

//statement 2

}

//method A

public static void addBonus(ref int balance)

{

balance = balance + 1000;

}

//method B

public static int addBonus(int balance)

{

return (balance + 1000);

}

4. Identify an example of one of each of the following GUI design errors in Figure 2:

inconsistency

misalignment

clutter

How could each of the three errors be corrected to improve the user experience?

Image Description

5. Although the following code compiles and runs, the programmer made some major readability errors. Describe at least three changes that would make it easier for other programmers to read and understand the code.

class Program

{

static void Main() //main

{

int a;

int Float = 10; // ints

for(int i = 0;i < Float;i++) /* loop */{

a=method(i);

Console.WriteLine(a);

}

Console.Read(); //read

}

public static int method(int a) /*method*/ {

return (int)(Math.Pow((double)a,2.0));

}

}

6. Write a C# program to store an array of integers 10 through 19. Use an appropriate loop to multiply all of the values in the list. Print out the result.

Reference no: EM131119666

Questions Cloud

Population heterogeneity or state dependence : Discuss the question whether people do or do not change over their life. Which theory do you think is more correct: population heterogeneity or state dependence?
Compute the amount of gross profit realized each year : Compute the amount of gross profit realized each year, assuming Wetzel uses the installment-sales method.
Compute the indirect quote for the rand rupee and yen : Compute the indirect quote for the rand, rupee, and yen as of February 20, 2004.
Asian american women and girls : What were some of the interesting aspects about Asian American women and girls' resistance to stereotypes?
Describe two types of loops that can be used to print : Describe two types of loops that can be used to print every third integer from 0 to 300 (i.e., 0, 3, 6, 9, etc.), each on its own line. Which would be a better choice and why? Write the code using that type of loop.
Determine the percentage change in the value : Determine the percentage change in the value of the following currencies relative to the U.S. dollar between November 15, 2001 and February 20, 2004.  a. Rupee b. Pound c. Yen d. Euro  e. Canadian dollar
Compute the amount of realized gross profit to be recognized : Compute the amount of realized gross profit to be recognized on the 2011 income statement, prepared using the installment-sales method.
What price must japanese motors charge for the same model : Japanese Motors exports cars and trucks to the U.S. market. On November 15, 2001, its most popular model was selling (wholesale) to U.S. dealers for $20,000.What price must Japanese Motors charge for the same model on February 20, 2004, to realize th..
Should this patient confidentiality be broken : A 16-year-old female presents to a family physician to obtain a referral for family therapy. She is estranged from her mother and stepfather, Should this patient's confidentiality be broken

Reviews

Write a Review

DOT NET Programming Questions & Answers

  Develop web services based application

Develop and test a Web services based application that meets the requirements applying SOA design principles.

  Design style elements in asp

Add drop down lists for modifying the different style elements for the label element that displays the time

  Create a shopping cart in asp

The users will use a browser to access the on-line store. The web server software for the production web server is Windows 2003 Server /IIS6.

  Inventory management system in c# application

Inventory management system in c# application

  Using .net resources to teach .net

This project will use the .NET framework to produce a set of materials to demonstrate the fundamental principles of .NET. Ideally it should demonstrate some of the principles of the framework e.g. interoperability.

  Prepare a marymount faculty site

Prepare a Marymount faculty site

  Blinky lights

Analysis proving that your code blinks the LEDs at the specified rates.

  Prepare a web application

Prepare a web application that will be used to keep track of patients registering in a hospital.

  Implementing the insurance management system

Implementing the Insurance Management System and implementation of Components as Web Services.

  Describe the characteristics of visual studio 2005

Describe the characteristics of Visual Studio 2005 Visual Studio.Net is a suite of products that includes 4 main languages. Name these languages and outline their use in industries

  What is a connectionstring

What is a ConnectionString. Give a suitable example to illustrate the various part of a ConnectionString

  Prepare a web application for internet service provider

Prepare a Web application and write the code also event planning document base. This web application allows the user to sign up for an Internet service provider for home connectivity.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd