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

For each of the problems below you are to consider making a function to solve th

ID: 3593466 • Letter: F

Question

For each of the problems below you are to consider making a function to solve the problem. As before, state the purpose of the function in your own words. Next specify input that is needed for the function to complete the task, and state what input should be passed to the function as parameters and what would be acquired inside the function using the input function. Specify the expected output and state if the output will be sent back to the function call or be sent to the monitor. Finally ,give the step by step process that will obtain the output from the input (the algorithm). In addition to these 4 items also specify test data that can be used for each function. Remember to describe your steps in enough detail so someone other than you could follow your algorithm and solve the problem. Also do not write any actual code

. Problem 1: Describe a function (mini-program) that will accept change needed from a purchase and determine the number of quarters, number of dimes, number of nickels, and number of pennies needed to make the change if you want to minimize the total number of coins used

Problem 2: Describe a function (mini-progam) that would accept 7 values from the function call and determine the minimum of those 7 values. Design this function without using the idea of arrays. Send back to the function call the minimum value. Hint, you should use no more than 7 comparisons (relational operators) to find the minimum.

Program 3: Describe a function (mini-program) that will prompt the user to enter 50 whole numbers and count how many even and odd numbers were entered (0 should be considered an even number)

Explanation / Answer

Program for 1st question: Go through all programs and give feedback to us.

// This function is used to take a sum of money input from user for which we have to provide change
// Input needed for this task is a float number as money in dollor . e.g : 2.65$ etc.
// The money value enteres by user will be passed as parameter to the change(), but No inputs are required inside the function definition.
// Output will be seven lines saying how many dollor coins.half dollor coins, dimes,nickel etc. are required to fulfill the requirement.
// output will be sent to monitor only, not return to the main() function.
// algorithm followed:
// step 1: call the change() function from the main() and pass the money value as parameter to this function
// step 2: change the given money in dollor to cents by doing (money_in_cents<moneyc>=money*100)
// step 3: program will do as following :
// step 4: if moneyc >= 100 cnts then store dcoins=moneyc/100 and substract dcoins*100 from moneyc.
// similarly check if money>=50 and money<100 , store hdcoins=moneyc/50 and substract hdcoins*50 from moneyc.
// step 5: repeat the above steps 4 for all others coins and store the result in appropriate variable.
// step 6: finally display the result on the monitor.

#include<iostream>
using namespace std;
int main()
{   void change(float);
   float money;
   cout<<"enter the money ";
   cin>>money;
   change(money);
  
  
  
}

void change(float money)
{
   float moneyc=money*100;int dcoin=0,hdcoin=0,qcoin=0,nicoin=0,dmcoin=0,penny=0;
   cout<<"money in cents==>"<<moneyc;
   if(moneyc>=100)
   {
   dcoin=moneyc/100;
   moneyc=moneyc-dcoin*100;
    }
     if(moneyc>=50&&moneyc<100)
    {
       hdcoin=moneyc/50;
       moneyc=moneyc-hdcoin*50;
   }
   if(moneyc>=25&&moneyc<50)
    {
       qcoin=moneyc/25;
       moneyc=moneyc-qcoin*25;
   }
   if(moneyc>=10&&moneyc<25)
    {
       dmcoin=moneyc/10;
       moneyc=moneyc-dmcoin*10;
   }
   if(moneyc>=5&&moneyc<10)
    {
       nicoin=moneyc/5;
       moneyc=moneyc-nicoin*5;
   }
   if(moneyc>=1&&moneyc<5)
    {
       penny=moneyc/1;
       moneyc=moneyc-penny*1;
   }
  
   cout<<"number of 1 dollor coins used==>"<<dcoin;
   cout<" ";
   cout<<"number of half dollor coinrsused==>"<<hdcoin;
   cout<" ";
   cout<<"number of quaters coins used==>"<<qcoin;
   cout<" ";
   cout<<"number of dime coins used==>"<<dmcoin;
   cout<" ";
   cout<<"number of nickel coins used==>"<<nicoin;
   cout<" ";
   cout<<"number of pennies coins used==>"<<penny;
   cout<" ";
}

program for 2nd question:

#include<iostream>
using namespace std;
int main()
{
   int min(int,int,int,int,int,int,int);
   int ans=min(10,2,30,23,40,31,11);
   cout<<"min value is "<<ans;
}

// This function is used to take 7 inputs from the user and determine the lowest of all the numbers
// that user has entered.
// Input needed for this task is 7 numbers(including 0).
// All input is passed as arguements to the function.
// Output will be one lines saying which is the lowest number of all 7 numbers.
// output will be sent to monitor only.
// step 1: call the min() function from the main() and pass 7 parameters from it
// step 2: declare a variable min and allot it a value equal to first parameter.
// step 3: program will check for min number as follows:
// step 4: the program will compare the next arguements with the min variable
//          if min < nxt parameter then:
            // min=nxt parameter;
// step 5: repeat step 4 for all parameters and determine the lowest number and save the result in min variable.

// step 6: finally display the result on the monitor.
int min(int a,int b,int c,int d,int e,int f,int g)
{
   int min=a;
   if(min>b)
   min=b;
    if(min>c)
    min=c;
    if(min>d)
    min=d;
    if(min>e)
    min=e;
    if(min>f)
    min=f;
    if(min>g)
    min=g;
    return min;
}

program for 3rd question:

#include<iostream>
using namespace std;
int main()
{
   void check_even_odd();
   check_even_odd();
}
// This function is used to take 50 inputs from user and determine the how many even or odd number
// user has entered.
// Input needed for this task is 50 numbers(including 0).
// No iput passed as parameters, but 50 inputs are required inside the function definition.
// Output will be two lines saying how many even or how many odd numbers user has entered.
// output will be sent to monitor only.
// step 1: call the check_even_odd() function from the main()
// step 2: provide the 50 inputs asked by the program
// step 3: program will check for each number as :
// step 4: if input number is divisble by 2 --> number is even----> incrrement the even flag by 1
//         else ---> number is odd----> increment the odd flag by 1

// step 5: finally display the result on the monitor.
void check_even_odd()
{
   int i=0;int even=0;int odd=0;int n;3
   cout<<"enter 50 numbers ";
   for(i=0;i<50;i++)
   {
      
       cin>>n;
       if(n%2==0||n==0)
       even++;
       else
       odd++;
   }
   cout<<"number of even numbers=>"<<even;
   cout<<"number of odd numbers=>"<<odd;
}