The program shall:
• generate a random number from 1 to 50 for a player to guess;
• display a message that indicates whether the player's guess is correct, too low, or too high; • prompt the user to keep on guessing until the correct value is entered
4. Create a try-catch structure that will handle two (2) exceptions. These are when the user inputs the following:
• a number that is out of range (1 - 50) a letter or any non-numeric character
5. Prompt the user so that he can guess again if an exception is thrown.
6. Display the number of total guesses.
Note: An invalid input (when an exception is thrown) is not considered a valid guess or attempt.
Sample Output:
Guess a number from 1 to 50!
30
Too high. Try Again.
10
Too high. Try again
qwerty
Invalid input.
Guess a number from 1 to 50!
51
Out of range.
Guess a number from 1 to 50!
1
Too low. Try Again.
H=11.3cm is the height of the triangle.
B=8.7cm is the base of the triangle.
Create a class for the above triangle.
1.Create one default constructor.
2.Create four parameterized constructors .They would look
like-
·Constructor_name(double, double)
.Constructor_name(double, int)
.Constructor_name(int, double)
·Constructor_name(int, int)
3.Create one copy constructor.
4.Create a function which would show the area of the triangle.
5.Create a destructor.
Call each of the functions from main functions. Call Constructor
name(do.
int) using pass by value and Constructor name(int, double) by
pass by
reference.
Real life example of static data member in class
Write a program to display the first 7 multiples of 7 using both(for, while) loops
: Write a program to perform basic to class conversion [Such as there is a class named: “conversion” with data members: feet and inches (both int)] Convert basic type(int) height in terms of total number of inches into equivalent feet and inches (class type) and display output on screen.
Indivisible Numbers(using nested for loops)
fin
number of positive integers K <= N such that K is not
for
4
5
You are given a positive integer N Your task is to find the divisible by any of the following numbers 2, 3, 4, 5, 6, 7, 8, 9, 10
6 prin
Custa
Input
The first line of input is an integer N
Output
The output should be an integer representing the number of positive integers satisfying the above condition.
Explanation
In the given sample input
N = 11
1 is not divisible by any of 2, 3, 4, 5, 6, 7, 8, 9, 10
2 is divisible by
2
3 is divisible by 3
11 is not divisible by any of 2, 3, 4, 5, 6, 7, 8, 9, 10
There are two numbers that are not divisible by 2, 3, 4, 5, 6, 7,
8, 9, 10
So the count is 2.
So, the output should be 2.
Sample Input 1
11
Sample Output 1
2
4
5
6 prin
Sample Input 2
12
Sample Output 2
2
Sample Input 3
268
Sample Output 3
47
Write a menu driven C++ program that enables users to buy coffee from a shop. The program should propmt the user to enter choice of coffee they want and then comoute the total cost. The program should also allow users to repeated select options without exiting unless if the user has chosen a no option.
Write a python program that implements a “Fahrenheit to
Celsius converter”. Upon program execution, the user is prompted to enter a
temperature in Fahrenheit and the program will output the corresponding temperature in
Celsius. The formula to convert a temperature given in Fahrenheit (F) to a
temperature in Celsius (C) is C = (F - 32)/1.8. Your solution should make use of floating
point (non-integer) values to obtain full marks. If you are not able to work with floating
point numbers, then provide an implementation with integer values (in this case, you can
use the following formula: C = (F - 32)/2. A solution that works only with integer values
will result in a decrease of marks but part marks will be provided.
Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input begins with an integer indicating the number of integers that follow.
Ex: If the input is:
5 10 5 3 21 2
the output is:
2 and 3
You can assume that the list of integers will have at least 2 values.
To achieve the above, first read the integers into a vector.
Hint: Make sure to initialize the second smallest and smallest integers properly.
Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. That list is followed by two more integers representing lower and upper bounds of a range. Your program should output all integers from the list that are within that range (inclusive of the bounds). For coding simplicity, follow each output integer by a comma, even the last one. The output ends with a newline.
Ex: If the input is:
5 25 51 0 200 33
0 50
then the output is:
25,0,33,
(the bounds are 0-50, so 51 and 200 are out of range and thus not output).
To achieve the above, first read the list of integers into a vector.