Construct a simple simulation of ordering

Assignment Help C/C++ Programming
Reference no: EM131117506

Which will either square, cube or shrink an integer based off a menu selection. I can not seem to allow for a float to be the result of the shrink.

Every time I try to allow for a float I receive multiple errors.

The code that works with a basic integer is below, need something that returns a float result for the shrink in C.
#include

int main ()

{

/* variable definition: */

int intValue, menuSelect,Results;


intValue = 1;

// While a positive number

while (intValue > 0)

{

printf ("Enter a positive Integern: ");

scanf("%d", &intValue);

if (intValue > 0)

{

printf ("Enter 1 to calculate Square, 2 to Calculate Cube, Enter 3 to Calculate Shrink n: ");

scanf("%d", &menuSelect);

if (menuSelect == 1)

{

// Call the Square Function

Results = Square(intValue);

printf("Square of %d is %dn",intValue,Results);

}

else if (menuSelect == 2)

{

// Call the Cube function

Results = Cube(intValue);

printf("Cube of %d is %dn",intValue,Results);

}

else if (menuSelect == 3)

{

Results = Shrink(intValue);

printf("shrink of %d is %dn", intValue,Results);

}


else

printf("Invalid menu item, only 1 or 2 or 3 is acceptedn");

}

}

return 0;

}

/* function returning the Square of a number */

int Square(int value)

{

return value*value;

}

/* function returning the Cube of a number */

int Cube(int value)

{
return value*value*value;

}

int Shrink(int value)

{

return value*1/2;

}

Reference no: EM131117506

Questions Cloud

What is the company cost of equity : The Muse Co. just issued a dividend of $ 2.75 per share on its common stock. The company is expected to maintain a constant 5.8 percent growth rate in its dividends indefi nitely. If the stock sells for $ 59 a share, what is the company’s cost of equ..
What is the company pretax cost of debt : Mudvayne, Inc., is trying to determine its cost of debt. The fi rm has a debt issue outstanding with 18 years to maturity that is quoted at 107 percent of face value. The issue makes semiannual payments and has an embedded cost of 6 percent annually...
Safety representative for your work group : You work in a large department store and are the newly appointed health and safety representative for your work group. The organisation is wanting in compliance with its health and safety compliance.
Describe what makes that decision unethical : Describe what makes that decision unethical. Present an alternative ethical and legal solution to the decision focusing on the organization's responsibility to its stakeholders.
Construct a simple simulation of ordering : You will use threads to construct a simple simulation of ordering at a coffee shop - Which will either square, cube or shrink an integer based off a menu selection. I can not seem to allow for a float to be the result of the shrink.
Environmental issues in today political world : Politicians that follow the dictates of their constituencies and the demands of reelection are followers. Is there a place for political leaders on environmental issues in today's political world?
Question regarding the monetary policy : 1. What policy instruments does the Fed use for the monetary policy?
Adapted from a case written by glyn jones : Matalvi Engineering Ltd has its headquarters in Hamilton, New Zealand, with manufacturing plants in South Auckland and Christchurch. The company manufactures equipment for the dairy industry. In its early years it focused on the domestic market, b..
Display a calendar for a specified month : You also can run the program without the year. In this case, the year is the current year. If you run the program without specifying a month and a year, the month is the current month.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Write a program the recursive algorithm for towers of hanoi

Write a program the recursive algorithm for towers of Hanoi. Write a program the iterative algorithm of Towers of Hanoi.

  After the user presses any key

After the user presses any key, the board will be scrambled by making a large number of random moves (for a 3x3 puzzle, 100,000 attempted random moves in random directions will result in a sufficiently scrambled board)

  The goal of this project is to create

The goal of this project is to create a simple command line program that reads in a single word from the command line (use the "int argc, char * argv[]" approach discussed in class and in previous projects) and stores the unique letters of that wo..

  Program that asks the user to enter the monthly costs

write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile:

  What is direct recursion

suppose hat intArray is an array of integers, and length specifies the number of elements in intArray. Also suppose that low and high are two integers such that 0

  Prepare a linear support vector machine svm

Write a computer program to prepare a Linear Support Vector Machine SVM

  Show the contents of the id array

Show the contents of the id array after each union operation when you use the quick find algorithm (Program below) to solve the connectivity problem for the sequence 0-2, 1-4, 2-5, 3-6, 0-4, 6-0, and 1-3.

  Lab9 c c programplease use functions there is the details

c program ltbrgtplease use functions ltbrgtthere is the details on the attachment.zip file needs to rework on this

  Write an array-returning method

Write an array-returning method that takes a two-dimensional array of chars as a parameter and returns a single-dimensional array of Strings as follows:

  Write a program that reads letters from a file

This program should open an inputLet.txt file , read in one character at a time and repeat this for the number of games the user wants to play.

  Program which calculates the average and sum of the numbers

write down a program which calculates the average and sum of the numbers enter by a user.Using a While Loop

  Implement a class timedepositaccount

It is not possible to deposit additional funds into this account. Provide a withdraw method that removes the entire balance. Partial withdrawals are not allowed.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd