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 c program which takes a string from command line

Write a c program which takes a string from command line with mainfunction has no parameter and convert the string in upperca

  Explain the data types used in c language

What is data type? Explain the data types used in C language.Write a program and draw a flowchart to print 1 to 100 all natural numbers.

  What are the different structured loops

Which piece of pseudocode represent the checking the loop condition

  Create a program that stores names in an array

In c++ create a program that stores names in an array. Also the program will end when "quit" is entered. Use a menu with the options: getName, sortName,displayName, findName, removeName.

  Is it always better to write optimal code

Specifically discuss the potential tradeoff between an easy to understand inefficient solution vs a difficult to follow efficient solution. Is it always better to write optimal code if the end result is difficult to follow by future programmers wh..

  You need to prepare an array in c++

You need to prepare an array in C++. The example I am using is different session of summer camp week 1-8, and then after you have selected the week session breaking the campers into four groups ages 5-8? Any assistance?

  Find the immediate next prime number

Find the immediate next prime number.

  Program to print out invalid number to character

The integer must contain 3 distinct non-zero number, or the program will print out invalid number.it should print out invalid query.

  Analyzing a property of an algorithm

Problems in Computer Science are often classified as belonging to a certain class of problems (e.g., NP, Unsolvable, Recursive). In this problem you will be analyzing a property of an algorithm whose classification is not known for all possible in..

  A pattern detector has an input

A pattern detector has an input a 4 x 4 matrix whose elements take values a, b, c, or d. The output is 1 if the matrix contains one b surrounded by eight a's and 0 otherwise.

  Write function that return number of occurrence of character

Write a function that returns the number of occurrences of a given character within a given C-string. Write and test the strrchr() function. Write and test the strstr() function. Write and test the strncpy() function.

  Region to minimize total time

Which salesperson should be assigned to each region to minimize total time? Identify the optimal assignments and compute total minimum time using Solver in Excel.

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