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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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