Question

In: Computer Science

C# Programming using Windows Form 1. Define a variable named isTrue that stores a value of...

C# Programming using Windows Form


1. Define a variable named isTrue that stores a value of
whether something is true or false. Set this variable
   to the negative. Output this variable to the txtIsTrue textbox.

2. Define a variable named favoriteGame that could store
the name of a game. Set this variable's value to your favorite game. Output this variable to the txtFavoriteGame textbox.

3.. Define a variable named pi that can store real numbers. initialize it to a value of 3.14. Output the value to txtPi

4. Create a control structure that will print out "That's Right"
to a textbox named txtRightOrWrong if isTrue from the 1st problem is positive result and "Nope" if isTrue is not true.

5. Write a loop of your choosing to print out the following
numbers to txtLoop textbox: -1 -3 -5 -7 -9 -13 -15 -17
  

6. Write a nested loop to print out the following to txtNestedLoop:
0
0 1
0 2 4
0 3 6 9
0 4 8 16 32
  

7. Call the method from number 8 and output the result to xtMethodCall textbox.

8. Create a method called Foo that takes an integer from
txtForFoo and returns Bar the amount of times entered.
ex: txtForFoo is 2 the result is "Bar Bar".

9. Add a try catch block in the Foo method to catch the  generic exception and one other exception of your choosing
bonus 5 pts if it applies to the method.

10. Create an array of 2 DateTime objects. Set the first
to the current date and time. Set the second to the
current date. Output both dates with a space between
them to txtDates.

/* ***BONUS***
Time how long it takes from the loading of the program
until the run button finishes running the first time it
is clicked.

Solutions

Expert Solution

Question 1:

Answer :

bool isTrue = false;
txtIsTrue.Text = isTrue.ToString();//display isTrue in the textbox

Explanation :Below screen shows the value in the textbox

**************************************

Question 2:

Answer :

string favoriteGame = "NFS";
txtFavoriteGame.Text = favoriteGame;

Explanation :Below screen shows the game name in the variable textbox

**************************************

Question 3:

Answer :

double pi = 3.14;
txtPi.Text = pi.ToString();

Explanation :

**************************************

Question 4:

Answer :

bool isTrue = true;
if(isTrue)
{
//when isTrue is true
txtRightOrWrong.Text = "That's Right";//set text
}
else
{
//when isTrue is false
txtRightOrWrong.Text = "Nope";
}

Explanation :

**************************************

Question 5:

Answer :

//using for loop
for (int i = -1; i >= -17; i=i-2)
{
txtLoop.Text += i + " ";//display text in the txtLoop textbox
}

Explanation :Below screen shows the text in the textbox

**************************************

Question 7,8,9:

public static string Foo(int num)
{
string str = "";//declaring variable str
for (int i = 0; i < num; i++)
{
str += "Bar" + " ";//append Bar
}
return str;
}
try
{
xtMethodCall.Text=Foo(int.Parse(txtForFoo.Text)).ToString();//call method
}
catch (FormatException f)
{
MessageBox.Show(f.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}

**************************************


Related Solutions

Write a Windows Form application named SumFiveInts. Microsoft Visual C#: An Introduction to Object-Oriented Programming,7th Edition....
Write a Windows Form application named SumFiveInts. Microsoft Visual C#: An Introduction to Object-Oriented Programming,7th Edition. Ch. 5, page 220. Take snip of program results.
C# Programming Discuss how to build a Multi-Form Windows application in C#. That is an App...
C# Programming Discuss how to build a Multi-Form Windows application in C#. That is an App that has more than one form, like say maybe 5 forms. How do you connect these forms and pass data objects between these forms?
C# Programming; Create a Windows Form Application that displays a scrollable list of 10 random integers...
C# Programming; Create a Windows Form Application that displays a scrollable list of 10 random integers in the range of 1 to 100. The form should also have (1) an Add button (and input textbox) for the user to add a new number to the list, (2) a Delete button to delete the current selected integer, (3) a Sort button to sort the list, (4) a Reverse button to display the list in reverse order, and (5) Display Multiple (and...
Define a class named Document that contains a member variable of type String named text that stores any textual content for the document.
Define a class named Document that contains a member variable of type String named text that stores any textual content for the document. Create a method named toString() that returns the text field and also include a method to set this value. Next, define a class for Email that is derived from Document and includes member variables for the sender, recipient, and title of an email message. Implement appropriate accessor and mutator methods. The body of the email message should...
Define a class named Document that contains an instance variable of type String named text that stores any textual content for the document.
IN JavaDefine a class named Document that contains an instance variable of type String named text that stores any textual content for the document. Create a method named toString that returns the text field and also include a method to set this value. Next, define a class for Email that is derived from Document and includes instance variables for the sender, recipient, and title of an email message. Implement appropriate set and get methods. The body of the email message...
Define a class named Document that contains an instance variable of type String named text that stores any textual content for the document.
Code in Java Define a class named Document that contains an instance variable of type String named text that stores any textual content for the document. Create a method named toString that returns the text field and also include a method to set this value.Next, define a class for Email that is derived from Document and includes instance variables for the sender, recipient, and title of an email message. Implement appropriate set and get methods. The body of the email message...
Define a class named Document that contains an instance variable of type String named text that stores any textual content for the document.
IN JAVADefine a class named Document that contains an instance variable of type String named text that stores any textual content for the document. Create a method named toString that returns the text field and also include a method to set this value.Next, define a class for Email that is derived from Document and includes instance variables for the sender, recipient, and title of an email message. Implement appropriate set and get methods. The body of the email message should...
Using C# Windows App Form Create a simple calculator using +,-,*,/ Please show code GUI Code...
Using C# Windows App Form Create a simple calculator using +,-,*,/ Please show code GUI Code for calculator menus radio button input text boxes
1. Select the answer that declares a variable named c that is a C character, initialized...
1. Select the answer that declares a variable named c that is a C character, initialized to the value A. char *c = 'A'; char c = 'A'; char c = "A"; char *c = "A"; 2. Fill in the missing code to produce the desired output: int a = 0; int b = 1; int c; // Missing code goes here printf("%d", c); Desired output: 1 -c = a && b; -c = a || b; -Answer not given...
a) b) c) Compare and contrast systems programming in Windows as against systems programming in Unix/Linux....
a) b) c) Compare and contrast systems programming in Windows as against systems programming in Unix/Linux. CR, 8 Explain the term structured exception handling (SEH) as used in systems programming and give a practical example of how it can be used to handle errors in a block of code. AP, 7 Write a C/C++ system program to delete an unwanted file in the Windows file system. Compile and run the program and copy the source code into your answer booklet....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT