Lab U12 -- Some Programming Practice (20 pts) -- due the end of Unit 1
The objectives of this lab exercise are to:
1. Make sure you understand the concept of operator precedence in C++
expressions and statements.
2. Take simple problem descriptions and produce small but complete C++
programs that solve these problems.
3. Give you some practice in using simple C++ interactive input and output
capabilities.
4. Give you some practice in the simplest decision statement (if).
Specifications:
This is a four-part exercise (a-d).
a. For the three assignment statements listed below, label the operators according to the order
they will be evaluated, i.e., label the first evaluated operator with a 1, the second with a 2, and
so on (see pages 57 and 58 of your text for examples of how to do this). Then fill in the blank
with the result assigned to variable x in each part.
i. x = 7 + 3 * 6 / 2 – 1;
x = ________
ii. x = 2 % 2 + 2 * 2 – 2 / 2;
x = ________
iii. x = ( 3 * 9 * ( 3 + ( 9 * 3 / 3 ) ) );
x = ________
b. Write a C++ program that inputs three (3) integers from the keyboard and prints the sum,
average, product, smallest and largest of these numbers. For this exercise you may assume the
user does NOT enter any duplicate values. The interactive screen dialogue should look
something like this (user input is shown in bold):
Input three different integers separated by spaces: 13 27 14
Sum is 54
Average is 18
Product is 4914
Smallest is 13
Largest is 27
c. Write a C++ program that reads in the radius of a circle and prints the circle’s diameter,
circumference, and area. Declare and use the constant 3.1415926 for p. Do the calculations
for diameter, circumference and area in the output statements (HINT: this means you do
NOT need variables for holding your calculated values of diameter, circumference, or
area).
For 5 points extra credit: determine the volume of a sphere using the radius…. Note on
your lab that you implemented this extra credit option.
d. Write a C++ program that reads an integer and determines and prints whether it is odd or
even. (Hint: Use the modulus operator (%). An even number is a multiple of 2 and any
multiple of 2 leaves a remainder of zero (0) when divided by 2).
I have answered all the question along with the extra credit point question..Do give a thumps up.Any Doubt please comment.
A.

B. Code In C++.
#include<iostream>
using namespace std;
int main(){
int num1,num2,num3;
cout<<"Input three different integers separated by spaces"<<endl;
cin>>num1>>num2>>num3;
cout<<"Sum = "<<num1+num2+num3<<endl;
cout<<"Average = "<<(num1+num2+num3)/3<<endl;
cout<<"Product = "<<num1*num2*num3<<endl;
//Smallest
if(num1<num2 && num1<num3)
cout<<"Smallest = "<<num1+num2+num3<<endl;
if(num2<num3 && num2<num1)
cout<<"Smallest = "<<num1+num2+num3<<endl;
if(num3<num2 && num3<num1)
cout<<"Smallest = "<<num1+num2+num3<<endl;
//Largest
if(num1>num2 && num1>num3)
cout<<"Largest = "<<num1+num2+num3<<endl;
if(num2>num3 && num2>num1)
cout<<"Largest = "<<num1+num2+num3<<endl;
if(num3>num2 && num3>num1)
cout<<"Largest = "<<num1+num2+num3<<endl;
return 0;
}
C. Code In C++
#include <iostream>
using namespace std;
int main()
{
float rad;
const float pi = 3.1415926;
cout << "Enter the radius of circle" << endl;
cin >> rad;
cout << "Diameter =" << rad * 2 << endl;
cout << "Circumference =" << rad * 2 * pi << endl;
cout << "Area =" << pi * rad * rad << endl;
float vol = 4.0 * pi * rad * rad * rad;
vol = vol / 3;
cout << "Volume =" << vol << endl;
return 0;
}
D . Code In C++
#include <iostream>
using namespace std;
int main()
{
int num;
cout << "Enter a Number" << endl;
cin >> num;
if (num % 2 == 0)
{
cout << "Number Is Even" << endl;
}
else
{
cout << "Number Is Odd" << endl;
}
return 0;
}
ai) (7+ ((3*6)/2)) - -> (7 + (18/2)) - = ( 7+9) -1 = 15 a 2) (C21. 2) + (2*2)) - (2/2) = (0+4)-(1) 3 a3> 3*q* (3+ CC9* 3/3)) = 3 *q* (3.8942 (9)) = 27* 12 = 324 .
Lab U12 -- Some Programming Practice (20 pts) -- due the end of Unit 1 The...
On question 1-3 can you please answer each script separately.
Please Use Perl Scripting
1. write a program that computes the circumference of a circle with a radius of 12.5. Circumference is 2π times the radius (approximately 2 times 3.141592654). The answer you get should be about 78.5. 2. Modify the program from the previous exercise to prompt for and accept a radius from the person running the program So, if the user enters 12.5 for the radius, she should...
1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...
C++ Write a program that reads three positive integers (> 0) from the command line (one at a time), then computes and prints the smallest entered number. Use if-else statements for three integer comparison. Example: Enter an integer: 5 Enter an integer: 23 Enter an integer: 7 The smallest number is: 5 Example 2: Enter an integer: 3 Enter an integer: 3 Enter an integer: 6 The smallest number is: 3 "The input must be positive number. The program should...
For this lab you will be creating a class representing the shape square. A Square is a special case of a Rectangle where both sides have the same length. Rectangle has been provided for your use in this lab. A Rectangle has a height and a width as member variables, two constructors, two member functions, area() and perimeter(), and lastly, an input and output operator. Your Square class should publicly inherit from Rectangle. You will need to update the Constructors...
please can you help me with this problem in C programminig language
C 6.33 LAB: Max And Min Number: x + m/zybook/NORMANDALECSC11111BenekeSpring2020/chapter/3/section/21 SCI 1111: Programming in C home > 3.21: LAB: Smallest number 3.21 LAB: Smallest number Write a program whose inputs are three integers, and whose output is the smallest of the three values. Ex: If the input is: 7 15 3 the output is:
Overview These exercises will allow you to have some practice with basic Java file Input/Output. In addition, you will also have an opportunity to have more practice with methods and arrays. Objectives Practice with programming fundamentals Variables - Declaration and Assignment Primitive types Arithmetic Expressions Simple keyboard input and text display output Branching - if-elseif-else syntax Loops - simple while loops, nested while loops Methods - functions and procedures ArrayLists - collections of variables File I/O Works towards the following...
iIn python please
AutoSave H L04-3b Testing Lab - Protected View - Saved to this PC- Search A Jharrah375@outlook.com J 7 File Home Insert Draw Design Layout Share Comments References Mailings Review View Help Areas and Volumes We'll write a program that prompts the user for a radius and then prints: a) The area and circumference of a circle with that radius b) The volume and surface area of a sphere with that radius 1. To get started, what is...
please solve it before 11:15 today
Subject :C++ programming
- Lab_9_Sec 51.pdf 1411113: Programming for Engineers Fall 2017/2018 LAB #9 Name: ID: Date Section Objectives: After completing this lab, you will be able to .Analyze a problem. .Implement the solution in C++ . Practice arrays and strings. Lab Exc. Mark Score Correct input/output Computational correctness Correct input/output Computational correctness Exercise#1: Number of occurrences in an array Write a program that fills an array with 10 random numbers between 0 and...
Please go to the Practice Exercises (at the end of Chapter 3 in your text on page 129) and do Exercise E 3.14 which asks you to compute and print the current season of the year depending on the month and day (input as integers). Be sure to review Java boolean operators, multi-way IF-ELSE statements, Switch statements, and String comparison methods before implementing your Java code. The algorithm for this program has been written for you and is included in...