The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 399 Weeks Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
C# Questions
1. Write a console program that takes the x-y coordinates of a point in the Cartesian plane (typed in by the user from the keyboard) and displays a message telling either an axis on which the point lies (if x or y are 0), or the quadrant in which it is found. Sample output: (-1.0, -2.5) is in quadrant 2 (0.0, 4.8) is on the y axis
2. What is the final value of S for the following code?
int I, X = 14; string S = ""; for (I = 1; I <= 3; I++) { X *= X * 3 % 50; if (X % 80 >50) S += "1" ; else if ((X % 80 >=30) && (X % 80 <= 70)) S += "2" ; else if (X % 80 < 25) S = "3"; else S += "Q"; } Console.WriteLine(S);
3. Given the following code, what is the final value of X written to the console? Show how you arrived at the result (intermediate values of X within the program) as well.
int N=0, M=0, I=0, X; X = Convert.ToInt32( 100.9 + (31.6 / Math.Pow( 2, 3)) * Math.Ceiling(-3.2)); if ((X < 36) || (X > M + N) && (X == 12)) { do { X += I; I += X; } while (I <= X); } else { if ((X==45) || ((X >=20) && (X<=80))) X +=1; else if ((X >=30) && (X<=90)) Convert.ToInt32(X /=2); else X=0; } Console.WriteLine(X); Console.ReadLine();
4. Write a console application that will be used in a factories train loading facility to track the number of train cars filled, the total tonnage filled, and the average tons per train car. The program should repeatedly prompt the user for the following until they enter 0 for the first question: Enter train weight in tons before loading (or zero to quit): Enter train weight in tons after loading: You should repeatedly ask these questions until the user enters 0 for the first question. When the user enters zero, output to the screen the total tonnage of product loaded unto the trains for the shift, the total number of train cards loaded, and the average weight in tons per train car. Also, check that the weight after loading is more than before (if not, ask the question over again until the user gets it right).
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll