#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y,n,i,j;
int a=rand()%31+10; //generating random numbers rand()%31 gives
numbers from 0 to 30
int b=rand()%31+10; //so 10 added for ranging from 10 to 40
if(a<b){ x=a; y=b;}
else{ x=b; y=a; }
cout<<"x : "<<x<<endl; cout<<"y :
"<<y<<endl;
while(1){
cout<<"Enter option, press 5 for exit : ";
cin>>n;
if(n==5) break;
else if(n==1){ //check no of perfect no from 1 to x
int c1=0;
for(j=1;j<=x;j++){
int sum1=0;
for (i=1;i<=j;i++)
if (j%i==0) sum1+=i;
if(j==sum1) c1++;
}
cout<<"Percentage of perfect no from 1 to "<<x<<"
is : "<<(c1*100.0/x)<<endl;
}
else if(n==2){ //no of odd divisors of x
int sum2=0,c2=0;
for (i=1;i<=x;i++) {
if (n%i==0 && i%2==1){
sum2+=i;
c2++;
}
}
cout<<"Average of odd divisors of "<<x<<" :
"<<(1.0*sum2/c2)<<endl;
}
else if(n==3){ //calculate sum of series
double sum3=0;
for(i=1;i<=x;i++) sum3+=1.0*x/pow(y,x);
cout<<"Sum of the series is :
"<<sum3<<endl;
}
else if(n==4){ // no of palindrome no between x to y and their
sum
int c=0,sum4=0;
for(i=x;i<=y;i++)
if(i%10== i/10){
c++;
sum4+=i;
}
cout<<"Total "<<c<<" numbers are palindrome and
sum of palindrome numbers is "<<sum4<<endl;
}
else{
cout<<"Entered wrong option."<<endl;
}
}
return 0;
}


GLOBAL A Mare out of bodo Question 2 Hagestion Write a C++ program to generate two...
Write a program that displays this to the user. "Hot Beverage Menu" "A: Coffee $1.00", "B: Tea $ 0.75", "C: Hot Chocolate $1.25", "D: Cappuccino S2.50", "E: Exit Menu" Prompt the user to make a selection. Determine which item the user entered. Use a do-while loop that keeps repeating till the user selects E from the Menu. If the user has selected a valid beverage, prompt the user for how many cups they would like, and print out how much...
Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...
extra credit 1 Write a program that will display the following menu and prompt the user for a selection: A) Add two numbers B) Subtract two numbers C) Multiply two numbers D) Divide two numbers X) Exit program The program should: display a hello message before presenting the menu accept both lower-case and upper-case selections for each of the menu choices display an error message if an invalid selection was entered (e.g. user enters E) prompt user for two numbers...
a. write a program that calculates the sum of two numbers x and y and then the program should call the function by address and prints the sum b. write a program that stores 10 integers provided at run time in an array. the program should prompt the user for a random integer exit in the array, the value must be replaced by a-1
Write a menu driven program to demonstrate the use of array and switch. It must be written in C language . Here is the menu - Press 1 to add a number to the array. Press 2 to display the numbers entered in the array so far Press 3 to find the average of the numbers entered. Press 4 to exit. Option 1 - The user should be able to enter 20 numbers only. If all twenty numbers are entered...
Write a program “hw4.c” that reads integer (less than or equal 100) from the keyboard and, on the output, writes the sum of the divisors of n (other than itself). For integers less than or equal to 1 it should print 0. For example, the input -3 0 1 4 5 6 12 should generate the output 0 0 0 3 1 6 16 Explanation of output: The input -3 is less than 1, output is 0. The input 0...
Use a java program that does the following:
. (10 points) Write a program as follows a. Prompt the user to input two positive integers: nl and n2 (nl should be less than n2) b. If the user enters the negative number(s), convert it/them to positive number(s) c. If nl is greater than n2, swap them. d. Use a while loop to output all the even numbers between nl and n2 e. Use a while loop to output the sum...
A Simple Calculator Summary: Write a console program (character based) to do simple calculations (addition, subtraction, multiplication and division) of two numbers, using your understanding of Java. Description: You need to write a program that will display a menu when it is run. The menu gives five choices of operation: addition, subtraction, multiplication, division, and a last choice to exit the program. It then prompts the user to make a choice of the calculation they want to do. Once the...
Part A) Write a C++ program that calculates the area under a curve. Here is the equation: f(x) = x^2 +1.5x +4 You must prompt the user for the beginning and the ending x values. You are to assume, but not check, that the user will put in whole positive numbers. The units are inches. The program input/output should look something like this: This program calculates the area under a curve between two points on the x axis. The equation...
Using C++ Requirements Note: “deque” STL container is not allowed, for the simplicity for graders. Queue Queue is a first-in-first-out (FIFO) data structure. For the Queue container, we will implement a program that simulates a buffer. The simulation needs a function that randomly generate number. And the buffer simulation starts with no value in the buffer. At the start of simulation, the menu should ask user: how many rounds will be simulated. the percentage chance to put a randomly generated...