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

  Advantages of compilers and interpreters

Discuss the advantages and disadvantages of compilers and interpreters

  Program to output value of tenth component of array

Write a C++ statements to perform the following: Set value of fourth component of array alpha to three times  value of eight component minus 57.

  Write a function called power that takes a double value

Write a function called power () that takes a double value for n and an int value for p and returns the result as double value. Use a default argument of 2for p, so that if this argument is omitted the number will be squared. Write a main () function..

  A c language program to implement the quicksort method

QUESTIONS:1. A c language program to implement the Quicksort method to sort a given data element list.2. A c language program to implement the Shortest Job First Algorithm method for CPU Scheduling of various process in   memory.

  Program that takes the purchase price of two item

Program that takes the purchase price of two items and compares the prices of those items under two different discounts (half-off the second item, and a percentage off both items (i.e. 10% off)).

  Create a global array of structures

Create a global array of structures with the following data. Each structure should store the data (Employee Table - Name, age, salary information) . Array size must be at least 10

  Evaluate the correctness and performance of your allocator

Repeatedly invoke the Ackermann function with increasingly larger values for n and m (be careful to keep n

  Find the concentration of a base used in titration

How would I find the concentration of a base used in titration given the following data: Volume of acid in Erlenmeyer flask = 25.00 mL (HCl) Molar concentration of acid in Erlenmeyer flask = 0.2127 M (HCl)

  Define and implement a default constructor for robot class

Define and implement a default constructor for the Robot class that sets the locations to zero, and load to false (no load is being carried by the Robot)

  Implemented a regular binary search tree

In Computer Science I, you implemented a regular binary search tree. Due to your busy schedule, you've decided that it would be best if you could simply reuse this code without any changes. You realize that your code would ONLY work for Arup's ass..

  Write a function to sum a list of numbers

Write a function to sum a list of numbers: (sum '(1 2 3 4))

  Machine that i would like to know

Let's say I have a machine that I would like to know, on average, how much it runs throughout a given day through a percentage value. Every 30 seconds, I will have a device to record the current temperature of the machine. If the machine increases..

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