Part 1 – Answer the following questions



Instructions:

1. Create a DOC file using Microsoft Word (or some other compatible word processor that can output Microsoft Word document files. Name the file COP2360_Assign2_Userid.DOC(x) replacing Userid with you user name. Put your name on each page of the document.

2. For Part 1, copy the equations/questions and place the answer after each.

3. For Part 2 and 3.

a. Write the pseudo-code for each program in a similar fashion as in the book.

b. Once the pseudo-code is complete, write a program that implements the pseudo-code.

c. Copy and paste the programs you wrote in VS2012 directly into your Word Document.

d. Take a screen shot of each program running and paste it into your Word Doc.

4. Parts 1 and 2 are due no later than Monday, September 28 by 11:59 PM

5. Part 3 is due no later than Friday, October 2 by 11:59 PM

6. Mail the Doc(s) file to:

Bradleyl@PalmBeachState.edu

Part 1 – Evaluate the following expressions or answer the question assuming these variables contain these values:

int a=3, b=4, c=5;

char c1 = 'A', c2 = 'a';

double x=2.3,y=3.3,z=4.3;

bool n=true;

1. 3.0 * 2.2 / 4 + b > c + 7 % 4;

2. b == (a + c) * 5 / 10;

3. (c1 > c2); //Explain you answer

4. (n || c == 2) && c == b;// – Explain your answer

5. n || (c == 2 && c == b);// – Explain your answer

6. What is potentially wrong with this statement

if (x+y+z==9.9)

{

Console.WriteLine(“Is Equal”);

}

• Each answer in Part 1 is worth 0.25 points (1.5 points total for the Questions).

Part II Design and write a program to calculate and display a person’s Body Mass Index (BMI).

BMI is an internationally used measure of obesity. Use the Internet to look-up the calculation for BMI based on US/Imperial measurements. Prompt the user for both their weight (in pounds) and height (in inches). Use the TryParse method when converting the input to numbers and display an error if incorrect information is entered. Use the height and weight to calculate the BMI. Once the BMI is calculated, display a message with the person’s BMI and status. The BMI status categories, as recognized by the U.S. Department of Health & Human Services, are as follows:

BMI Weight Status

Below 18.5 Underweight

18.5 - 24.9 Normal

25 - 29.9 Overweight

30 & above Obese

Before writing the program, write the pseudo-code/algorithms needed to accomplish the above task and include it in the document file.

• Make sure that good variable and constant names are used

• Make sure that the program is indented and commented correctly

• Make sure that good input prompts are used and that the output is clear.

• The algorithm/pseudo-code in Part 2 is worth 0.5 points.

• The program in Part 2 is worth 3 points.

• 1 Point Extra Credit Part 2 – Include the ability to repeat the process by asking the user if sh/e would like to run another calculation.

Part 3 – Design and write a program that reads in a file using ReadLine() and prints out a folio based on the information in the file.

The program should prompt for the full file-name and then open the file for input.

The file being read will contain a header record of the following format:

Last-Name (string 15 characters)

First-Name (string 15 characters)

Room Number (string 4 characters)

Check-Out Date (string format 11 characters)

Number of Days (integer 4 characters)

After the header record, the file will have a list of the charges incurred by the guest for his stay at the hotel. The charge records will have the following format:

Charge Date (string format 11 characters)

Charge Code (integer 1 character)

Taxable (Char Y = yes, N = no 1 character)

Charge Amount (float 10 characters)

Two files for this assignment have been posted to COP2360 Web Site, one named GoodFilio.txt that has no errors and another named BadFolio.txt that has an error in one of the charge amounts. These files should be placed in the Bin/Debug directories when testing you program.

Use the SubString method to separate the string returned by ReadLine() into each individual field. The program should first read the header record and then go into a while loop to pick up the charges.

Use the TryParse() method to convert the Charge Code and Charge Amount fields to Integer and Decimal numbers. If either conversion fails, display a message on the console and stop the program.

Charge Codes should be converted into Charge Descriptions by using a switch statement in a separate method.

1 = Room

2 = In-Room Video

3 = Internet Access

4 = Room Service

5 = Bar Charges

6 = Gift Store

If the Taxable field is set to ‘Y’, then 6% tax should be applied to the Charge Amount and a “Y” should appear in the Tax? column. Use a method to compute the extended amount that has as parameters the charge amount and the taxable flag.

The program should produce the following output (see extra credit note at end of assignment)

Palm Beach State Hotel

Folio for : First-Name Last-Name

Room: XXXX

Check-Out Date: DD-MMM-YYYY

Stay Days: 999

Date Charge Description Amount Tax? Extended Amount

DD-MMM-YYYY Room 99.99 Y 99.99

DD-MMM-YYYY Internet Access 99.99 Y 99.99

DD-MMM-YYYY Gift Store 99.99 Y 99.99

Folio Total 999.99

Before writing the program, write the pseudo-code/algorithms needed to accomplish the above task and include it in the document file.

• Make sure that good variable and constant names are used

• Make sure that the program is indented and commented correctly

• Make sure that good input prompts are used and that the output is clear.

• The instructions ask you to use two methods in the program. Make sure at least those two are used, but additional methods can be added if you want.

Grading

• The algorithm/pseudo-code in Part III is worth 1 point.

• The program in Part III is worth 4 points.

• 1 Point EXTRA CREDIT Part 3– Format the output using WriteLine Custom Format Parameters so that it looks like a Hotel folio and the output is nicely lined up as in the example

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download

To fulfill the demand for quickly locating and searching documents.

It is intelligent file search solution for home and business.

Literature Lottery

Related searches