Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have been confused on how to write algorithms from day one! I amcurrently taki

ID: 3615533 • Letter: I

Question

I have been confused on how to write algorithms from day one! I amcurrently taking an online class and am so lost with this topic. Wehave an assignment due in a week where we have to write analgorithm for a certain problem and then create a program for it.Here are my problems:
   1. Write a program to calculate the change inquarters, dimes, nickels, and pennies when any amount from 1 to 99is entered. The program should return the minimum coins thatrepresent the amount entered. For example 37 cents shouldyield one quarter, 1 dime, and two pennies.
   2. Write a program to find the smallest number, thelargest number, and the average of any five numbers entered by theuser. For example, if the five numbers entered are 1, 2, 3,4, and 5, the answers should be smallest =1, largest=2, andaverage=3. (Your program should handle any numbers from 1 to1,000)

So far what I have for the first one is:
cin>>inputCoins
while(inputCoins > 0)
{
if(inputCoins >= 25)
Quarters ++
inputCoins -= 25
elseif(inputCoins >= 10)
Dimes ++
inputCoins -= 10
elseif(inputCoins >=5)
Nickles ++
inputCoins -= 5
elseif(inputCoins >=1)
Pennies ++
inputCoins -= 1
}
cout>> //print your coin totals out here.

Is any of this right for the programming code? Skipped thealgorithm part because I am not even sure where to begin. As forthe second, I don't even know what to do.
Any tips? any help? SO CONFUSED!!!

Explanation / Answer


#include<iostream> #include<conio> using namespace std;
int main() { int num[5],v=0; for(;v<5;v++) { cout<<"Enter a Number "<<v+1; cin>>num[v]; }
int min=num[0]; int max=num[0]; int sum=0; float avg=0;
for(v=0;v<5;v++) { if(num[v]>max) max=num[v]; if(num[v]<min) min=num[v]; sum=sum+num[v]; } avg=sum/5;
cout<<"Largest Number="<<max; cout<<"Smallest Number="<min; cout<<"Average of Numbers="<<avg;
system("pause"); return 0; }
Hope it is helpful to you.
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote