I always give a positive rating! Language is C++ I know this looks really long, but this is actually pretty easy. Just f

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

I always give a positive rating! Language is C++ I know this looks really long, but this is actually pretty easy. Just f

Post by answerhappygod »

I always give a positive rating!
Language is C++
I know this looks really long, but this is actually
pretty easy.
Just follow the steps in the document below and paste
your code in the answer.
Thanks!
I Always Give A Positive Rating Language Is C I Know This Looks Really Long But This Is Actually Pretty Easy Just F 1
I Always Give A Positive Rating Language Is C I Know This Looks Really Long But This Is Actually Pretty Easy Just F 1 (143.02 KiB) Viewed 55 times
I Always Give A Positive Rating Language Is C I Know This Looks Really Long But This Is Actually Pretty Easy Just F 2
I Always Give A Positive Rating Language Is C I Know This Looks Really Long But This Is Actually Pretty Easy Just F 2 (62.11 KiB) Viewed 55 times
In-Class 3 Opening Files && Writing Expressions . . This exercise has you opening a file to read input from reading input, implementing expressions, and doing some formatting. You will read 2 ints and 2 doubles. You should Learn how to prompt for a file name and open the file for reading Read data from the opened file I.carn how to create a data file in CodeBlocks • Gain experience implementing expression, Use expressions (shown in texts and online) with integer division, but they need to be written in C-+ not using int constants. #4 and #5 cannot be written as 1/4 and 1/3 ! • Experience with formatting using fixed, sctprecision(), and sctwo. NOTE: Look at the Input/Output on pg 3!!! This indicates lines involved with producing Output. Steps for this assignment 1. Opening and reading from a file a. Prompt and read an input file name b. Open the file (show in class!!!) c. Read 2 integers from the file, into variable like inti and int2 Rcad 2 doubles from the filc, like dull and db12 e. Use the variable below. Declare variables for each of the following expressions, and print cach variable so you see what the expression does. To do this you can declare result1, result2, and result3, OR you can use just result, print the answer, reuse result, print the anser, reuse result and finally print the answer. i resulti = inti % int2; ii result2 = int2 % inti; iii. result3 = inti / int2; 2. Constants are usually made global, by declaring them above main() or in a header file. const double INCLASS3_PI = 3.14; 3. Now, use this definition of INCLASS3 PI, and add lines of code to calculate and to output the value for the area of a semi-circle, a. assign radius = dbli (from the file) b. semicircleArea = * INCLASS3_PI radius? when radius 11.10=> area 193.44 2. For the following pi and e lines of output, use fixed, setprecision (4), setw(12), right and the constants from the cmath lib M_PI and M_E from the math library. to print the following formatted lines. Print the characterstrinys p and e as labels for columns, then print the values for M_PI and M_E: 1234567890121234567890-231 (I show this line only to show spacing for the next lines.) р 3.1416 2.7183 cout the values of M_PI and M_E 3. Encode fahrenheit = 9.0/5.0 celsius + 32 assign celsius = db12 (use the double value from the file, e.g.-11.1) . 1

then print the following line celsius -11.10 = fahrenheit 12.02 cout the values of M PT and ME 4. Encode the following: fahi = (double) (9 / 5) + celsius + 32 fah2 = (double) 9 / 5 * celsius + 32 val fahi number ?=? val fah2 urber What is the difference between these expressions for fahl and fah2? (What is being made a doub e?) . 5. Encode double do varl = (1/4) * numOfSides *lengthOfSidesa * cot(Il’numOfSides) This is the formula for the area of a Regular 11-polygon. cot(x)=1/tan(x) Assign test values: numOfSides=6; and lengthOfSides=5; before the expression for dblvarl Result: dblvarl = 64.99 . . 6. Encode dolvar2 = (1/3)* P1* radiusOfCircle * heightOfCone This is the formula for the volume of a cone. Assign test values: radiusOfCircle = 5 and heightOfCone =10 Result: dblvar2 = 261.67 . 7. Encode do Var3 = 15 & 4 + 11 / 5 Can you change the 4 to 4.0? What happens and why? Change back the 4 and change the 11 to 11,0. What happens and why? Finally change the - in the expression to * and leave the 11 as 11.0, how does the expression evaluate and why? output dblvar3 = 6.60 . . 8. Encode dolvar4 - 11 / 5 + 11 / 5 • Why is the answer not 11 or 11.0? • Change the first 11 to 11.0. Why does this not still make the answer 4.4? Submit this last version that has only the first 11 as 11.0. output dblvar4 = 4.20 2

Input File Make an input file named inclass3input.txt and put this in it: 43 11 11.1 -11.1 Here is sample Input and Output based on reading these numbers from the file! To thoroughly test your program, you should change the values in the input file and hand check the ouput produced Input/Output Your output should look like this. (Please copy and paste the text from the prompts and text output into your code! You are graded based on the text by Web-CAT.) Name of input file: inclass3input.txt resulti = 10 result2 = 11 result3 = 3 radius 11.10 ==> area 193.44 P 3.1416 e 2.7183 celsius -11.10 = fahrenheit 12.02 fahl 20.90 ?==? fah2 12.02 dblvarl = 64.99 db Var2 = 261.67 dblvar3 = 6.60 db Var4 = 4.20 Programming Style An important part of programming is using proper programming style, formatting, and comments. At this point, the most important items are: . Use descriptive variable names Vertical (proper use of blank line mostly) and horizontal spacing (putting spaces around operators, indentation, etc.) o Indent properly - statements and braces should be lined up; auto-indent CSE Plugins Source Code Formatter (AStyle) in CodeBlocks

. USE in XCode default shortcut for Formatting is ctrl+I o Skip a line between each small section of your program, so that groups of related statements are logically grouped by separation with blank lines. Have a beginning comment that describes what the program is doing (just Homework 2" is not good enough). See the main Canvas page for Coding Guidelines about what every program header needs to contain Fach scction (i.c. logical chunk of code) begins with a comment describing what that section does, so that the comments alone would provide an outline of the program (It's NOT good to follow every line of code with a comment.) Continue typing your code on the next line if it is too long. Too long is over 80 characters. In Code::Blocks, there is a column indicator at the bottom-middle-ish of the screen that tells you which column the cursor is at. Submit Your Work To submit your work to Web-CAT to be graded. 4
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply