1 CMIS 102 Hands-On Lab Week 3 – Trapezoid araa Overview This hands-on lab allows you to follow and experiment with the critical steps of developing a program including the program description,...

1 answer below »
Need screenshots of work


1 CMIS 102 Hands-On Lab Week 3 – Trapezoid araa Overview This hands-on lab allows you to follow and experiment with the critical steps of developing a program including the program description, analysis, test plan, design, pseudocode visualization, and implementation with C code. The example provided uses mathematical operators and variable types. Program Description This program will calculate the area of a trapezoid. The program will ask the user to enter the two bases and height and then use these values to calculate and then print the area of the trapezoid. The design step will include pseudocode. Analysis I will use sequential programming statements. I will define three float numbers for the two bases and the height: baseA, baseB, height. Float numbers were selected as opposed to integers to make sure trapezoids of all dimensions are possible and not just whole numbers. Float number will store the area: area The area will be calculated by this formula: Area = ½ * (baseA + baseB) * height For example if the bases are 4.7 and 2.1, and the height is 5.3 the area is calculated as: Area = ½ * (4.7 + 2.1) * 5.3 = ½ * 6.8 * 5.3 = 3.4 * 5.3 = 18.02 Test Plan To verify this program is working properly the following baseA, baseB and height values could be used for testing: Test Case baseA baseB height Expected Output Notes: 1 3 4 5 17.5 Small integers 2 5 5 5 25 Square or Rhombus 3 0 3 4 6 Triangle 4 10.1 8.3 12.2 112.24 Some fractions 5 2.67 6.23 3.23 14.3735 More fractions 6 120 450 874 249090.000 Larger numbers 2 Pseudocode // This program will calculate the area of a trapezoid. // Declare variables Declare baseA, baseB, height, area as Float // Ask User for Inputs Write “Enter the first trapezoid base:” Input baseA Write “Enter the second trapezoid base:” Input baseB Write “Enter triangle height:” Input height // Set value of area Set area=1/2*(baseA + baseB) * height // Print area Print “Area of the trapezoid is “ + area C Code The following is the C Code that will compile in execute in the online compilers. // C code // This program will calculate the area of a trapezoid. // Developer: Faculty CMIS102 // Date: Jan 31, XXXX #include int main () { /* variable definition: */ float baseA, baseB, height, area; /* Prompt user for baseA */ printf("Enter the first base of the trapezoid: \n"); // Input the base scanf("%f", &baseA); /* Prompt user for baseB */ printf("Enter the second base of the trapezoid: \n"); // Input the baseB scanf("%f", &baseB); /* Prompt user for height */ printf("Enter the height of the trapezoid: \n"); // Input the height scanf("%f", &height); // Calculate the Area area= 0.5 * (baseA+ baseB) * height; // Print the result printf("Area is : %f\n", area); return 0; } 3 Setting up the code in repl.it: And the conversation panel: Note the bases and height (4.7, 2.1 and 5.3) are entered in as responses to the prompts. You can change these values to any valid float values to match your test cases. 4 Learning Exercises for you to complete 1. Demonstrate you successfully followed the steps in this lab by preparing screen captures of you running the lab as specified in the Instructions above. 2. Change the C code to calculate the perimeter of the corresponding right trapezoid, where two of the angles are 90°. Support your experimentation with a screen capture of an execution of the new code. A little geometry, using the Pythagorean Theorem, will derive the following formula for the perimeter: P = baseA + baseB + height + squareRoot (height^2 + (baseA – baseB)^2) Which can be coded as: perimeter = baseA + baseB + height + sqrt (height*height + (baseA – baseB)*(baseA – baseB)) NOTE: The code will also need the following include statement added just after the “#include “ line in the code: #include 3. Prepare a new test table with at least 3 distinct test cases listing input and expected output for the perimeter of a right trapezoid. 4. What is this line of code doing? scanf("%f", &height); How would you change this line if you wanted to input an Integer as opposed to a float? 5. What are the values of g and h after executing the following C code? #include int main(void) { int i,j; float f,g,h; i = 5; j = 2; f = 3.0; g = f + j / i; h = (f + j)/i; printf("values of g,h are %f,%f\n", g,h); return 0; } Describe specifically, and in your own words, why are the values of g and h different? Support your experimentation with a screen capture of an execution of the code. http://www.opengroup.org/onlinepubs/009695399/functions/printf.html 5 Submission Submit a neatly organized word (or PDF) document that demonstrates you successfully executed this lab on your machine using an online compiler. You should provide a screen capture of the resulting output. Also, provide the answers, associated screen captures, C Code and descriptions of your successful completion of all learning exercises listed above. The answers to the learning exercises, screen captures, C code and descriptions can be included in the same neatly organized document you prepared as you ran this lab. Note the code can be embedded in the word document. However; be sure all code compiles and runs perfectly before submitting the document. Submit your document no later than the due date listed in the syllabus or calendar. Grading guidelines Exercises Submission Points 1 Demonstrates the successful execution of this Lab within an online compiler. Provides supporting screen captures. 20 2 Modifies the code to also calculate the perimeter of a right trapezoid. 20 3 Provides a new test table with at least 3 distinct test cases listing input and expected output for the perimeter of a right trapezoid. 20 4 Accurately describes the purpose of the scanf code. Accurately describes how to modify the code to input an integer as opposed to a float. 20 5 Accurately describe why are the values of g and h different for the provided code? Supports your experimentation with screen captures of executing the code. 10 6 Document is well-organized, and contains minimal spelling and grammatical errors. 10 Total 100 Homework 2 – Test Case Creation Using the following pseudocode, provide 5 unique test cases that would help validate your algorithm. Be sure to place the test cases in a table showing the input values, and expected output for each test case. Write "Enter the price in dollars:" Input Price Write "Enter state sales tax(e.g. .06) :" Input SalesTax Set Price = Price + (Price * SalesTax) Write "Price with Tax is" + Price Submit your word or PDF file to your assignments folder no later than the due date. Grading guidelines Submission Points A minimum of 5 test cases were provided. 60 Input provided and explained for each test case. 10 Expected output provided and explained for each test case. 10 Test cases represent a wide variety of possible input values (e.g. large numbers, small numbers (0), negative, or unexpected non-number entries (%,”hello”…). 20 Total 100
Answered Same DayFeb 10, 2021

Answer To: 1 CMIS 102 Hands-On Lab Week 3 – Trapezoid araa Overview This hands-on lab allows you to follow and...

Neha answered on Feb 10 2021
146 Votes
50550/Homework 2.docx
Prerequisites
The price in dollars is declared as int data type.
Sales tax is declared as a float data type so it can accept float a
s well as int values.
The price is declared as float data type.
Test Case 1
Write "Enter the price in dollars:"
Input = 10000 //This input is large in size. The data type for this input will be int.
Write "Enter state sales tax (e.g. .06):"
Input = 0.70 // the input for sales tax can be a float value
Set Price = 10000+ (10000* 0.70)
Write "Price with Tax is" + 17000 // After calculating the price for price in dollar and sales tax for it, out put is 17000. 0.70 of 10000 will be 7000 and when it is added to 10000, it becomes 17000.
Test Case 2
Write "Enter the price in dollars:"
Input = 0 //This input is for smaller number. The smallest number for the test can be 0 only.
Write "Enter state sales tax (e.g. .06):"
Input = 0.0 // This is the minimum sales tax value we can have
Set Price = 0+ (0* 0.0)
Write "Price with Tax is" + 0.0 // The output for this case is 0 as when we multiple any number with zero only the zero will be returned.
Test Case 3
Write "Enter the price in dollars:"
Input = -100 //This input is for negative number. The int type can take input in negative but a price can never be in negative.
Write "Enter state sales tax (e.g. .06):"
Input = -0.7 // Similarly the sales tax can be zero but it can’t go negative. But int data type accepts the negative value
Set Price = -100 + (-100 * -0.7)
Write "Price with Tax is" + 0.0 //The output for these...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here