Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

| D https://myasucourses.asu.edu asu.csenuspreabap ' Sp19.pdf ebdav/pid-19771024-dt-content-rid-1463106573/courses/2019Spring-T-CSE110-16223/asu.cse110 Aon State University CSE 110-Lab 4 Lab Topics Getting familiar with loops Perfionming arithmetic operations inside the koop

image text in transcribed
image text in transcribed
image text in transcribed
| D https://myasucourses.asu.edu asu.csenuspreabap ' Sp19.pdf ebdav/pid-19771024-dt-content-rid-1463106573/courses/2019Spring-T-CSE110-16223/asu.cse110 Aon State University CSE 110-Lab 4 Lab Topics Getting familiar with loops Perfionming arithmetic operations inside the koop Use the following Coding Guidelines: Whe declaring a varsble, you wually wan to iniialine i Remember you cannot ntialire a nunber uith string. e Remember variable names are case sensitive Use tabs or spaces to indent code within hlocks (code surrounded by braces). This includes classes methods, and code associated with ifs, switches and kops. Be consistent with the number of spaces or tabs that you une to indent. Use whine space to make your progras more neadable. . Use commenes afher the ending hrace of classes, methouls, and blocks to identify to which block it belongs Lab Programming Problem In this lab, you need to design a program that can perform three different arithmetic operations based on the user's input. The three operations are I. Summation of integers from I to m 2. Factorial of a given number n (n 3. Finding the leftmost digit of a given integer inote: you have to use int) This program should prompt the user a mcou including four options, ask the user for one option, and perform the corresponding computation. This process will repeat until the user chooses "Quid" Please use this menu in your progra Please choose one option from the following nenu s 1) Calculate the sun of integers Ecom i to n 2) Caleulate the factorial of a given nunbe s 3) Display the Lettmost digit of a given nunber v/pid-19771024-dt-content-rid-1463106571/courses/2019Spring-T-CSE110-16223/asu_cse11 ASl Engineering Ariona Stale University Sample Output Below is an example of what your output should roughly look like when this lab is completed. Text in RED represents user input. Please choose one option from the following menu: 1) Calculate the sum of integers from 1 to m 2) Calculate the factorial of a given number 3) Display the leftmost digit of a given number 4) Quit Enter a number: The sum of i to 4 is 10 Please choose one option Erom the following menu 1) Calculate the sum of integers from tom 2) Calculate the factoril of a given number 3) Display the leftmost digit of a given number 4) Quit Enter a number: The factorial of 5 is 120 Please choose one opt ion from the foilowing senu: 1) Calculate the sum of integers from 1 to m 2) Calculate the factorial of a given number 3) Display the leftnost digit of a given numbez 4) ouit Enter a number s 87 654321 The Leftnost digit of 98765432lis9 Please choose one option from the tollowing menus 1) Caleulate the sun of integers fron 1 tom 21 Calculate the tactorial ot a given nunbe ) Display the lefmoss digit of a given numbe r 4) 945t ebdav/pid-19771024-dt-content-rid-1463106571/courses/2019Spring-T-CSE110-16223/asu.cse110 sp Program Design The following flowchart shows a skeleton of this lab program. You can declare as many variables as you like (omitted in the flowchart for readability). The processes asking the user for inputs should come with appropriate prompt messages (e.g., print "Please enter a number" before input functions). This program involves multiple conditions for optional computations. You must use a switch statement to implement this structure Please note if you use if-else statement, even though the logic is pretty much the same, you will not get any points for this part The program will stop when the user inputs an integer number 4. As described in the flowchart, the loop condition is situated at the end of the loop process. Therefore, you have to use a do-while statement to implement this logic. Please read the template file for the detailed instruction. These condtions should be

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Explain what companies are doing to reduce health-benefit costs.

Answered: 1 week ago