An important goal of this course is to develop students ability to solve problems using C++ programming. In this project, you are asked to solve a number of problems to develop this skill as well as review basic C++ constructs such as loops, decision statements, arrays, and expressions.
Learning Objectives
The focus of this assignment is the following learning objectives:
- Be able to solve problems using C++ programming
- Be able to identify appropriate C++ constructs for a specific problem.
Prerequisites
- To complete this project, you need to make sure that you have the following:
- C++ and the g++ compiler
- A C++ IDE or text editor (multiple editors exist for developers)
- An understanding of the basic C++ constructs.
Problem Description
Given the following problems, write C++ programs to solve any seven of these problems.
- Write a C++ program called cpp that reads an integer number into your program and prints out all factors of the number.
- Write a C++ program called cpp that reads an integer number into your program and counts the number of digits in the number. Example 1: 435 3, Example 2: 1992 4
- Write a C++ program called cpp that continuously accepts integers from the user and fills them into an integer array of 5 elements. The program stops accepting integers when the user enters a zero. At that point, the program prints the current content of the array. Filling of the array happens in a circular way. That means when the program reaches the end of the array, it wraps around and begins to override the numbers entered earlier. Initialize the array to zeros before beginning to accept input from the user.
Example 1: Assume that the array size is 5. If user input is 1,2,3,0 then the contents of the array = {1,2,3,0,0}
Example 2: Assume that the array size is 5. If user input is 1,2,3,4,5,6,7 then the contents of the array = {6,7,3,4,5} (after 5, the program wraps around and begin to fill the array from the beginning).
- Write a C++ program called cpp that accepts integers from the user and fills them into an integer array of 5 elements. Given this array of integers, check if the elements of the array are monotonically increasing. Example 1: a [] = {2 ,4, 6, 7, 10} True. Example 2: a [] = {2,3,4,1,5} False.
- Write a C++ program called cpp that prompts the user to enter the cartesian coordinates of the three vertex points ( x1, y1), ( x2, y2), ( x3, y3) of a triangle. Based on the locations of the vertex points of the triangle, your program must calculate and display its area. The different formula that can be used for calculating the area of a triangle are as follows: Semi Perimeter s = (side1 + side2 + side3)/ 2;
area = s( s side1)( s side2)( s side3)
The distance between two points that have their cartesian coordinates ( x1, y1) and ( x2, y2) can be found out by the formula
- Write a C++ program called cpp that reads an integer between 0 and 1000 and adds the cubes of all the digits in the integer. For example, if an integer is 432, the sum of the cubes all its digits is 43 + 33 + 23 = 64 + 27 + 8 = 95. If the user enters an input that is invalid, the program must show an error and ask the user to enter a valid number again.
- To find out the extent of coldness of the weather or the wind chill, certain other factors other than temperature need to be considered. Factors involving relative humidity, wind speed, and sunshine perform vital roles in defining the coldness outside. In 2001, the National Weather Service (NWS) implemented the new wind-chill temperature to measure the coldness using temperature and wind speed. The formula is given as follows:
twc = 35.74 + 0.6215ta 35.75v0.16 + 0.4275tav0.16
where ta is the outside temperature measure in degrees Fahrenheit and v is the wind speed in miles per hour. Twc is the wind-chill temperature. This formula cannot be used for wind speeds below 2 mph or temperatures below -58F or above 41F.
Write a C++ program called windchill.cpp that prompts the user to enter a temperature. If the temperature is between -55F and 45F and a wind speed greater than or equal to 2, the program calculates and displays the wind-chill temperature and then ends.
If the value entered by the user is outside the range, the program displays an error saying Value outside range) and keeps looping till the user enters a valid value.
- Write a C++ program called cpp that accepts an arbitrary floating-point value from standard input and returns the value truncated to the second position after the decimal (the hundredths place). The value needs to be printed to the screen according to the following format:
The truncated value is v.
The variable v needs to be substituted for the corresponding value. You may not use any library function or conditionals to compute the value. Instead, you must use simple multiplications, divisions, additions, and/or subtractions as well as type casts to calculate the truncated value and then print it to the screen. In the output, ensure that only two digits after the decimal point are shown in the output of v. For example, if you enter 3.768, the output should show the value 3.76.
- According to the Gregorian calendar, it was Monday on the date 01/01/1900. If any year is input through the keyboard, write a C++ program called cpp that to find out what is the day on 1st January of this year.
- Write a C++ program called cpp to accept unspecified number of integers from the user (every time the user enters a number, the program asks if the user wants to enter another number). When the user finishes entering numbers, the program displays the count of positive, negative and zeros entered.
- Write a C++ program called cpp to find the octal equivalent of the entered number.
Reviews
There are no reviews yet.