A2

pdf

School

Arizona State University *

*We aren’t endorsed by this school

Course

100

Subject

Computer Science

Date

Dec 6, 2023

Type

pdf

Pages

6

Uploaded by ChefClover20268

Report
Assignment 2 - Due on Feb. 15 CSE 100 Assignment # 2 Maximum Points: 20 NO LATE ASSIGNMENTS WILL BE ACCEPTED. Due Date: February 3rd by 11:59PM Topics: o Understanding topics in chapters 2 & 3 & 4 e expressions o if-else statement e swifch statement Your programming assignments require individual work and effort to be of any benefit. Every student must work independently on his or her assignments. You must work alone on the assignments no collaboration of any kind is permitted. You cannot use Google, StackOverflow, Chegg or any other on-line resources to look up for the solution. Sharing your assignments with others in any way is NOT permitted. Violations of the University Academic Integrity policy will not be ignored. Assignments Documentation: At the beginning of each programming assignment you must have a comment block with the following information: [ // AUTHOR: your name I/l FILENAME: title of the source file // SPECIFICATION: description of the program // YOUR Lab Letter and Name of the TA for your lab I/ FOR: CSE 100- homework #- days and time of your class // TIME SPENT: how long it took you to complete the assignment // */ Reasonably good amount of comments should be added in your program so that it is easy for other people to understand it.
Important Note: All submitted assignments must begin with the descriptive co the one shown above. It must contain your name and lab letter, and the other To avoid losing trivial points, make sure this comment header is included in eve submit, and that it is updated accordingly from assignment to assignment. Part 1: Written Exercises: (5 points) 1. Given the following switch statement where x is an int, answer the next two switch (x) { case 3 : x +=1; break; case case case case case case X += 2; ¢ X += 3; DX+ ¢ X += 2; T X--3 POX++ WO NGV b a) If x is currently equal to 5, what will the value of x be after the switch state b) If x is currently equal to 3, what will the value of x be after the switch statem #include <iostream> using namespace std; int main() { int score = 65; // Initialize student's test score if (score = 100) cout << "You made a perfect score.\n"; if (score != 100) cout << "You needed " << 100 - score << " more points for a perfect : return 0; } a) What do you think the program will print when it is run? b) Find the logic error in the program and fix it so that the program produces th Write down the correct output it now displays. ¢) Replace the two if statement in the program with a single if/else statement. | Your assignment is to write a complete C++ program that is capable of reprodt sample runs shown at the end of this handout. All text characters shown in the examples, except for the values typed by the user, are written to the screen by Note that the user is prompted to enter an integer value for each run of the prc program displays the following menu: Geometry Calculator
1. Calculate the Area of a Circle 2. Calculate the Area of Rectangle 3. Calculate the Area of a Triangle 4. Quit Enter your choice (1 -4): If the user enters 1, the program should ask for the radius of the circle and the area. Use the Math function to get the value of the Pl. If the user enters ch¢ program should ask for the length and width of the rectangle, and then display rectangle’s area. If the user enters choice 3, the program should ask for the lel triangle’s base and its height, and then displays its area. If the user enters cho program should end. Input Validation: Display an error message if the user enters a number outsic 1 through 4 when selecting an item from the menu. Do not accept negative val circle’s radius, the rectangle’s length or width, or the triangle’s base or height. Do not use loops to validate the input since we haven't covered chapter 5. You else statements to validate the input once. Program requirements and/or constraints: Create your plan BEFORE you begin to write the code See the sample output for formatting. Use iomanip features to format rat spaces. Use comments freely throughout the program No global variables allowed! (-5 points) Your program must work for any valid input - not just the values shown in output. Do not use material beyond the current topics Do your own work. Sample runs: User input is represented in RED
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Geometry Calculator 1. Calculate the area of a Circle 2. Calculate the area of a Rectangle 3. Calculate the area of a Triangle 4. Quit Enter your choice (1-4): 1 Enter the circle's radius: 23 The area is 1661.90 Enter your choice (1-4): 2 Enter the rectangle's length: 2 Enter the rectangle's width: 45 The area is 90.00 Enter your choice (1-4): 3 Enter the length of the base: 67 Enter the triangle's height: 34 The area is 1139.00 Enter your choice (1-4): 4 Sample run 2: Geometry Calculator 1. Calculate the area of a Circle 2. Calculate the area of a Rectangle 3. Calculate the area of a Triangle 4. Quit Enter your choice (1-4): 2 Enter the rectangle's length: 45 Enter the rectangle's width: 23.5 The area is 1057.50 Enter your choice (1-4): 2 Enter the rectangle's length: 23 Enter the rectangle's width: 1 The area is 23.00 Enter your choice (1-4): 3 Enter the length of the base: 23 Enter the triangle's height: 12.5 The area is 143.75 Enter your choice (1-4): 1 Enter the circle's radius: 23.56 The area is 1743.81 Enter your choice (1-4): 4 Sample run 3: Geometry Calculator 1. Calculate the area of a Circle 2. Calculate the area of a Rectangle 3. Calculate the area of a Triangle 4, Quit Enter your choice (1-4): 5
You may only enter 1, 2, 3, or 4, Enter your choice (1-4): 1 Enter the circle's radius: 2 The area is 12.57 Enter your choice (1-4): 3 Enter the length of the base: -3 Enter the triangle's height: -19 Only enter positive values for base and height. Enter your choice (1-4): 7 You may only enter 1, 2, 3, or 4. Enter your choice (1-4): 4 Grading criteria: Part 1 - 5 points Programming: (15 points) 4 pts - Documentation & indentation & spacing(header with your name, your program description and comments within your code) 3 pts- Variable names are descriptive & use of constants with correct conven 8 pts - correct outputs/results 20 points total Submit your homework by following the instructions below: dhkkkhkkkkkhkkhkkhhkkhkkhkhkdkkhkkhkhkkkkkkhkkkhkkkkhkkkhkkkkkkkhkkkhkdkkhkhkhkkhkkkhhkkhkkhkhkkkkk Go to our course website and log onto Canvas, https://my.asu.edu 1. From the left-hand side control panel, click on "Gradescope", it will bring yi website, 2. Once inside the Gradescope, from the left hand side, click on Assignments Assignment 2 is already posted, click on Assignment 2. 3. "Click to browse" to find where you saved the Assignment2.cpp file. Assigr have the following, in order: 1. In comments, the assignment Header described in "Important Note". 2. Only the answers to questions in part 1 in comment block , for examp 3. The working C++ code requested in Part 2.
4. "Upload" button located at the bottom to submit. 5. If you submit the correct file and your program compiles successfully and ¢ expected output, you will see a green message with 8 pts assigned automatis to edit your source code and click on the low right corner "Resubmit" button t assignment file. 6. For all labs and assignments, you have unlimited times to resubmit before time. Gradescope will only record your last submission! 7. To pass the two auto test cases on Gradescope, your program's output ne our solution output. (Empty space doesn't count, only characters count), we r use a file comparison program, such as diffMerge or the following online one they contains the same outputs or not. 8. The remaining points will be checked and assigned by our graders manua assignment’s due date. Note: It's your responsibility to make sure you submit the source codes corre TA, grader and myself will NOT reply and accept any late submissions throug Copyright © 2023 Arizona State University All rights reserved. ACIl Aisaalainmaam flabbrnclhhamamar mais asdsslaainmsrala/ldiaalali;ceaw/
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help