Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

BIT 1 4 0 0 Assignment 3 Summer 2 0 2 4 Let s see if we can do something similar to A 2 so

BIT 1400 Assignment 3 Summer 2024
Lets see if we can do something similar to A2 so everyone feels more comfortable with C programming
and algorithmic thinking. In this assignment you will:
1. Begin thinking about code reuse and identifying why functions can be useful.
2. Demonstrate the ability to write syntactically and logically correct C code for math operations.
3. Compose logically sound and unambiguous pseudocode for a real world calculation problem.
Part 1: Pseudocode
Submit a pseudocode solution for finding concern students in BIT 1400 if all students and their grades
were written in an excel spreadsheet (ie a big grid of students and their grades). On each row of the
spreadsheet is a students information. Columns in the table will be student name, assignment 1 grades
(%), assignment 2 grades (%), and 4 lab attendance grades (listed as true/false). For each subroutine,
just refer to it and define later.
A student is considered a concern student if they didnt attend at least 3 of the 4 labs so far and didnt
pass both assignment 1 and assignment 2.
Make sure you define any subroutines you write.
Pseudocode will be loosely defined as any algorithmic (and non-ambiguous) set of instructions that are
performed one after the other. Therefore, flow charts and step-by-step instructions would both count.
If some part of the task is ambiguous either, ask or clearly state the assumptions you are making.
If you write your instructions on paper, take clear easy-to-read photos and put them all into a single pdf
file. If you write the pseudocode on a computer (I dont recommend this without a digital pen, but it is
your choice) then make a pdf of your work. Submit this pdf file to Brightspace.
Part 2: Variables and basic functions
This assignment is still attempting to ease you in to programming in C
If you programmed before; dont worry. The problems are about to be more challenging. In the
meantime, you should solve these problems using (reusable) functions for a bit more of a challenge
(experienced programmers ONLY). If A2 was too hard, hopefully this will restore some confidence.
Make a new project with a single .cpp file titled A3_.cpp, where is your first
initial and last name. Put a main method in the .cpp file.
In the main method, make a new constant (const) double variable named MY_PI. MY_PI should be
equal to 3.14159.
Make two variables (double data type) named radius and diameter. Set the diameter to 2 and radius is
always diameter /2.
To test your code, you can modify the value of radius and make sure your code works for
different values.
Set the value back to 2 before submitting your work but write comments stating the values you
tested and the results you got.
Area of a Circle:
Make a variable areaCircle (a double) and calculate the area of a circle with the given radius (the
variable above). Recall that the area of a circle is pi * r2 but there is no need for a square function. You
just need * for multiply.
Use printf to write a message about the area of the circle.
Volume of a Cylinder:
When calculating the volume of a cylinder, we will make the height of the cylinder equal to the
diameter.
You should test that the cylinder volume calculation works for multiple different diameters.
Make a variable volumeCyl (double) that stores the volume of a cylinder.
Use printf to write a message about the volume of the cylinder.
Volume of a cylinder (intro to functions): Notice how much nicer it would be if we just wrote the area of
a circle code just once?
Incorrect Volume
Try to calculate the volume of a sphere with integers only: 4/3* pi * r * r * r
To make sure each number is an integer and NOT a double or float, you can put (int) in front of each
non-integer. Something like:
int sphereVol =4/3*(int) MY_PI *(int)radius *(int) radius *(int) radius;
Next, calculate sphereVol2 as the correct calculation but cast the final number to be an int. That would
look something like:
int sphereVol2=(int)(4/3* MY_PI.......);
Calculate sphereVol3 which CORRECTLY calculates the volume of the sphere. SphereVol3 should be a
double.
Finally, using printf statements to output the values (and meaningful messages) of sphereVol,
sphereVol2, and sphereVol3.
Printf is a function that lets you output messages to the screen. It has a format like this:
printf(Some message to output %i, myVal);
Lets say myVal was 4, the message Some message to output 4 would appear in the output window.
Recall that %f is for floats and doubles while %i and %d are for integer digits. Please see the lab TAs for
help if you are confused. You may also look at assignment 2 for help.
Also note:
in the text message makes a new line. Therefore
printf(Some message to output
%i
,3);
outputs
Some message to output
3
Calculating Cube Volume
Finally calculate the volume of a cube with dimensions diameter x diameter x diameter where
diameter is the diameter variable you made at the start of t

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