ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 11 May 2017 My Price 9.00

1CMIS 102 Hands-On LabWeek 7

#include <stdio.h>

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 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

       printf("Invalid menu item, only 1 or 2 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;

}

 

1CMIS 102 Hands-On LabWeek 7OverviewThis hands-on lab allows you to follow and experiment with the critical steps of developing a programincluding the program description, analysis, test plan, design, and implementation with C code.Theexample provided uses sequential, repetition, selection statements and two user-defined function.Program DescriptionThis program will provide options for a user to calculate the square or cube of a positive Integer input bya user. The program will prompt the user to enter an Integer and then prompt the user if they want tocalculate the square of the cube of the number. Based on the inputs of the user, the program will outputthe square of the cube of the positive integer. The program will then print the Integer and square orcube of the integer based on the user’s original choice. The program will continue to prompt the user forIntegers and their calculation choice until the user enters a negative integer. The square and cubecalculations should be calculated using a function.AnalysisI will use sequential, selection, and repetition programming statements and functions for the cube andsquare calculations.I will define three Integer numbers: IntValue, MenuSelect, Results to store the Integer value input by theuser, the Menu selection (1 for Square, 2 for Cube) of the user, and the results of the Square or Cubefunctions.The Square function will take one Integer as input and return one Integer as the output. The calculationwithin the Square function is: Results = IntValue * IntValueFor example, if 10 was entered as the IntValue. Results = 10*10 = 100The Cube function will take one Integer as input and return one Integer as the output. The calculationwithin the Cube function is: Results = IntValue * IntValue*IntValueFor example, if 10 was entered as the IntValue. Results = 10*10*10 = 1000A repetition loop can be used to loop through iterations until a negative is entered:while(intValue > 0) (…End For

Attachments:

Answers

(11)
Status NEW Posted 11 May 2017 12:05 AM My Price 9.00

-----------

Attachments

file 1494461845-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)