Free Essay

Cmis 102

In:

Submitted By rogersj1206
Words 790
Pages 4
Pseudocode for the program
// Declaring variables
Declare Integer InternetHits[10]
Declare Integer i
// Loop for inputting values
For i = 0 to 9
Print 'Enter the value-' Print i+1
Input InternetHits[i]
End For
// End of Program.

1. #include <stdio.h> 2. int main () { 3. int internetHits[10]; 4. int hits; 5. int counter; 6. for(counter=0;counter<10;counter++){ 7. printf("Enter number of hits: "); 8. scanf("%d",&internetHits[counter]); 9. } 10. //Display Values 11. printf("Entered values are: \n"); 12. for (counter = 0;counter<10;counter++){ 13. printf("%d\n",internetHits[counter]); 14. } 15. return 0; 16. }

*************************************************************************

Question

Design and write a program, using functions, that calculates the area and perimeter of a rectangle whose dimensions (length and width) are provided by a user.
There are 4 components of your submission including:
Program Description- A detailed, clear description of the program you are building.
Analysis- Demonstrates your thought process and steps used to analyze the problem. Be sure to include the required input and output and how you will obtain the required output from the given input? Also, include your variable names and definitions. Be sure to describe the necessary formulas and sample calculations that might be needed. Talk about how your design will allow any number of students and final grades to be possible inputs.
Test plan - Prepare at least 3 sets of input data (Test data) along with their expected output for testing your program. Your test data can be presented in the form of a table as follows (note: feel free to adapt to your design)
Pseudocode- Provide pseudocode of your overall design that fulfills the requirements of the project
All of these components should be placed in word document for submission.
Answer
*
Gavin Pence Chegg expert answered this 1 hour later
Was this answer helpful?
1
0
2,771 answers
Gavin Pence
2,771 answers
"I'm a Computer geek-I can help students hone their programming skills!"
Top Subjects: Computer Science, Electrical Engineering, Other Math
Provided 4 components as per your requirements.
1) Program Description: * Read input for length and width of the rectangle values from the user. * Calculate the area and perimeter values by using functions. * Display the area and perimeter of the rectangle.
C Program Code:
//Header file section
#include<stdio.h>
//Function prototypes float calcArea(float length, float width); float calcPerimeter(float length, float width);
//main method int main()
{
//Declare variables float length,width; float resArea,resPer;
//Prompt and read input from the user printf("Enter length of the rectangle: "); scanf("%f",&length); while(length<0)
{
printf("Enter Length Again {Negative Values Not Allowed}: "); scanf("%f",&length);
}
printf("Enter width of the rectangle: "); scanf("%f",&width); while(width<0)
{
printf("Enter Width Again {Negative Values Not Allowed}: "); scanf("%f",&width);
}
resArea=calcArea(length,width); resPer=calcPerimeter(length,width); //Display output printf("Area of a rectangle = %.2f \nPerimter of a rectangle= %.2f \n",resArea, resPer); return 0;
}
//Function definition of calcArea to compute the area of a rectangle area =l*b float calcArea(float length, float width)
{
return length*width;
}
//Function definition of calcPerimeter to compute the perimeter of a rectangle p =2(l+b) float calcPerimeter(float length, float width)
{
return 2*(length+ width);
}
2) Analysis:
Program contains three modules: main, calcArea, and calcPermiter.
In main: * Declare variables: length,width, resArea, and resPer. * Prompt and read the length of the rectangle and width of the rectangle from the user. * Check the input values are negative or not. If it is negative, again read the positive values otherwise go to call the functions, calcArea, and calcPermiter. * CalcArea function result stored in variable, resArea and calcPermiter function result stored in resPer. * Display the output as the area and perimeter values of a rectangle. calcArea function: * The function calcArea accepts the length and with parameter values and calculate the area of the rectangle by using formula: length*width. Finally return the result. calcPermiter function: * The function calcArea accepts the length and with parameter values and calculate the perimeter of the rectangle by using formula: 2*(length+ width). Finally return the result.
3) Test plan:
Prepared three sets of input data (Test data) along with their expected output for testing your program. Your test data can be presented in the form of a table as follows:

Sample Output screen shot: 4) Pseudocode:
Module main () Declare width, length, resArea, resPer as float Display “Enter length of the rectangle:“ Input length Display “Enter width of the rectangle:“ Input width resArea = calcArea(length,width) resPer = calcPerimeter(length, width) Print resArea, resPer
End Main
Module calcArea(length,width) Return with length*width
End calcArea
Module calcPerimeter(length, width) Return with 2*(length+ width);
End calcPerimeter

Similar Documents

Free Essay

Cmis 102

...Course: CMIS 102  Date: 1/23/2014 Problem: Calculate the usable area in square feet of house.  Assume that the house has a maximum of four rooms, and that each room is rectangular. We are trying to calculate the square feet of a 4 bedroom house To do this, I will need to know each room’s length and breadth, then calculate each room’s area before I will then find the total. Map: When * = times Sum = total Room# =Room number Length# = length or a particular room Breadth# = breadth or a particular room Formula: Area of Room1=length1*breadth1 Area of Room2=length2*breadth2 Area of Room3=length3*breadth3 Area of Room4=length4*breadth4 The total Number of Square Foot’s = Area of room1+ Area of room2+ Area of room3+ Area of room4 Program Design Pseudo code: Start Declare the variables v ,A as integer length[4], breadth[4],area[4] as double array sum as double Display “Enter the Rooms length and Breadth” For v = 1 to 4 do Accept length[v], breadth[v] Next v Display “Finding Area and total number of square foots” Set sum =0 For A= 1 to 4 Area [A] = length [A]* breadth [A] Sum = sum + Area [A] Next A Display “Total number of square foots”, sum Stop Program Comments and Test Data C++ code: #include<iostream> #include<string> Using namespace std; int main() { int v,A; double length[4], breadth[4] ,area[4], sum; } cout<<"\nEnter the length and breadth of each room"; for (v=0;v<4;v++) { cout<<"\nRoom "<<v+1<<"...

Words: 420 - Pages: 2

Premium Essay

Cmis 102

...1. Problem definition: Design a program that will allow a user to Input a list of your family members along with their age and state where they reside. Determine and print the average age of your family and print the names of anyone who live in Texas. 2. Problem Analysis: The program will inform user to input family member name, age and state. The program will take the years of all members entered and add them together and then take the total of members entered (10) and divide the total coming up with the average age. The program will also calculate and identify each state of each person entered and using the defined input identifies those people from Texas and prints their names out only. The output of the program is three fold. The total average age of all family entries, identify who is from TX and print their name out. The program is to calculate the total average of the family age wise and determine their location with only printing out those members that are from Texas (TX). The program will take inputs from the user who will input the name, age and location of each family member. The program will take the years of all members entered and add them together and then take the total of members entered (10) and divide the total coming up with the average age. The program will also calculate and identify each state of each person entered and using the defined input identifies those people from Texas and prints their names out only. The output of the program is three fold...

Words: 517 - Pages: 3

Premium Essay

Cmis 102

...1. Problem definition: Design a program that will allow a user to Input a list of your family members along with their age and state where they reside. Determine and print the average age of your family and print the names of anyone who live in Texas. Note: Your problem analysis should have already been submitted as part 1 of the assignment. A. Program Design – Following the directions in the assignment, clearly write up your problem design in this section and comment your pseudocode. Complete Pseudocode With Comments: // Family Member Data // Programmer: J. West, University of Iowa // Version 1.0 – October 9, 2014 /* This program allows the user to input family data and print the average age of their family and the names of any relatives that live in the state Texas. */ // Variables used: // FamMbrName = Family member’s name (As String) // Age[ ] = Array name (As Integer) // State = State family member resides (As String) // OutOfState = Family Members that live in the state of Texas (As String) // AverageAge = Sum of age of family members divided by 10 (As Float) // Names[ ] = Array name (As String) // Count = Counter (As String) // YearsOld = Age of family members (As Integer) // Y = Identifies family member (As Integer) // Z = Identifies age (As Integer) // AgeSum = Sum of the ages of the family members (As Float) // NewAvgAge = Sum of age of family members divided by 10 (As Float) Main module Declare Names[10], FamMbrName, State, OutOfState As...

Words: 781 - Pages: 4

Premium Essay

Cmis 102

...1.What information do you consider important to be conveying to the general public regarding the impact of the acute usage of alcohol on the body? usage of alcohol can have many negative effects on the body. Over time and with long term use an individual can develop both physical and emotional symptoms. Physical symptoms can include liver failure, changes in brain function. 2. Discuss the arguments for and against classifying alcohol dependence as a disease. Are there differences with drug addiction? How about compulsive gambling? Alcoholism is a primary chronic disease with genetic psychosocial and environmental factors influencing its development and manifestations. The disease is often progressive and fatal. People use the terms drug abuse and addiction. One can abuse drugs without necessarily being addicted to drugs. Drugs abuse specifically requires that drugs have a negative effect on the user’s life. Drug addiction the addict has developed a tolerance to drugs increasing the used amount and experiences withdrawal. Compulsive gambling disorder is uncontrollable urge to keep gambling despite the tool it takes on your life. 3. One treatment method utilized for withdrawal is pharmacologic treatment. Discuss your perspectives of using pharmacologic treatment, what are the pros and cons?   treatment for alcohol withdrawal is only works if the patient is correctly taking the medication. If a patient would rather drink thank take the prescribed medication than the...

Words: 253 - Pages: 2

Free Essay

Cmis 102

...Lot's of Stuff We all spend a lot of time and energy trying to do many things, but do we spend time on what’s really important? Indicate how much time you spend on, or how important the following are to you. (Be honest) ACTIVITY Going online to chat with friends or check emails Spending time to get a guy or girl notice you Working to get a car, or for money to buy gas and insurance Playing sports, practicing, or traveling around to compete Attending church youth functions, camps or outreach events Doing homework or studying for that exam Sitting in front of the television or surfing the Internet Listening to music or going to concerts Spending quality time alone with God LOW HIGH 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 Discussion Questions: ● ● ● ● If you feel comfortable doing so, share your answers with others in your group. Does spending time alone with God take a priority over everything else? Are there any activities in your life that you are spending too much time on? Isn't it okay to spend lots of time on things you really enjoy, as long as it isn't something bad?...

Words: 278 - Pages: 2

Free Essay

Cmis 102

...Program Description: The program I am building determines the square footage of homes and/or rooms. This program provides custom specification that provides the exact square footage of usable living space. Analysis: In this program the objective to obtain square feet of a house. The results are the output, which is required to know the exact square footage of the entire house. The house contains four rooms that are all rectangular. My output will be obtained by finding the area of each room. The formula to achieve this is: Length x Width (LxW). The area of each is room then summed up to determine to actual square footage of the house, which is the actual usable living space. The variable name is “a” for area which was used to test and run the program. Please see calculations and table: Area of Room 1= Length1 x Width1 (14*12)=168 Area of Room 2= Length2 x Width2 (9*12)= 108 Area of Room 3= Length3 x Width3 (8*11)= 88 Area of Room 4= Length4 x Width4 (13*13) =169 Area of Room 1 + Room 2 + Room 3 =Room 4 = Total Square footage (533) Useable square footage of a house Total number of Rooms = 4 Area=L x W of each room Variables= Area Perform Calculations: Length x Width Room 1 = 168 Length x Width Room 2 = 108 Length x Width Room 3 = 88 Length x Width Room 4 =169 Output Results: 168+108+88+169= 533 Pseudocode Test 1: #include int main () { /* variable definition: */ int a ; /* variable initialization */ a = 14*12+9*12+8*11+13*13 ;printf("Integers...

Words: 367 - Pages: 2

Free Essay

Cmis 102 Hw2

...CMIS102 Homework Assignment 2 Student Name: Class/Section: CMIS 102/ 3110 Professor Name: Assignment due date: 03 February 2014 Problem definition: Calculate the total price to purchase all the components required to build a state-of-the-art gaming computer from components available on the internet. A. Problem Analysis – Following the directions in the assignment, clearly write up your problem analysis in this section. We are writing a program to calculate the total cost of a gaming computer system. The total cost the computer system should be calculated using the following formula (TotalCost= CpuChoiceCost + RAMChoiceCost + HardDriveCost + ComponentsCost). The cost will be represented by integers. The results should be placed in variable TotalCost. The inputs, for the program are: ComponentsCost, TotalCost, A to Q, Yes or No The output for the program is TotalCost As Float. B. Program Design – Following the directions in the assignment, clearly write up your problem design in this section and comment your pseudocode. Main Module Declare MotherboardCost, CpuChoiceCost, SounCardCost, GraphicsCardCost, CaseCost, MonitorCost, PowerSupplyCost, DVDDriveCost, HardDriveCost, RAMChoiceCost, OperatingSystemCost AS Character Declare A to R As Integer Display a Welcome message Write “Welcome to Computer World” // Prompt for and input start building your system: Write “Would you like to start building your System?” Input Yes OR No Display...

Words: 955 - Pages: 4

Premium Essay

Cmis 102 Final

...CMIS 102 Final Project CMIS 102 6984 Rebecca Rowson Due: March 29th 2015 Problem Definition: We have been contracted to develop a program that will allow a user to put in the age and names of family members along with the state that they each reside. The program will then take the ages and find the average age of the family members and print the name of anyone who lives in Texas. Problem Analysis: Desired Output: The desired output will be all input names that are from the state of Texas. As well as finding the Average age of the family members. Required Input: The user will be required to input the name of family members as well as the age of the family members and the state in which they reside. Calculations: Divide: totalage / numfamily Program Design: To start out this program out I will set the array “familymembers[50]” to 0. Then I will set “newmember” to 1 set as integer. Then I will set the array “state[50]” to 0, set “count” to 1, set “totalage” to 0, set “numfamily” to 0, set “age” to 0, set “Aveage” to 0. We will then display "We will now require you to input information about your family members, beginning with name.” Start a loop on the condition that “newmember” = 0 or “count” > 50. If No then the user will be asked to input the name of a family member and will store it in “familymembers[count]”. Next they will be asked what state this family member lives in and store it in “state[count]”. We will lastly ask the user how old this family member...

Words: 617 - Pages: 3

Free Essay

Cmis 102 Hw3

...Problem definition: Write a program that will calculate and display the average of an unknown number of positive floating point values entered by a user. A. Problem Analysis – Following the directions in the assignment, clearly write up your problem analysis in this section. What is the required output? The calculated average of all the numbers the user input. What is the required input? The numbers that are greater than or equal to 0 that the user wants to find the average of. A number less than 0 (any negative number) to tell the program to end the input module and start the process module. How will you obtain the output from the given input? number – (float) the number(s) the user input that they want to find the average of. count – (integer) the total number of numbers the user inputs that are greater than or equal to 0 sum – (float) the total of all the numbers the user inputs. average = (float) the average of all the numbers the user inputs. Formula – Set sum = 0.0 Set count = 0 While number >= 0 then Set sum = sum + number Set count = count + 1 End While Set number = sum / count Sample Calculation If user inputs 30, 20, 50, and -2 Input 30 While number >=0 then 30>=0 is true go to enter while loop Set sum = sum + number 0 + 30 = 30 Set count = count + 1 0 + 1 = 1 Input 20 While number >=0 then 20>=0 is true continue in while loop Set sum = sum + number 30 + 20 = 50 Set count = count + 1 1 + 1 = 2 Input 50 While number...

Words: 559 - Pages: 3

Free Essay

Cmis 102 Homework 1

...Peter Doyle CMIS 102 Prof. Tanney HW1 Purpose of the program This program will be used to determine the square feet of usable space in each individual room and those values will be added together to get the total usable area of square feet in house with length and width values of up to four rooms being the only known value BEGIN define variables for rooms and total usable space room numbers and area of each room will be will be represented by integers r1 through r4 total usable area in the house will be represented by Usable_space which define variables of length and width for r1-r4, integer l1,l2,l3,l4,w1,w2,w3,w4 //the values for length and width will be added by user input l1,w1,l2,w2,l3,w3,l4,w4 //Length will be known as L and will have the integers of L1 through L4. L1through L4 will correspsond to the the integer “L” with the same number //Width will be known as “W” and will have the integers of w1 through w4 with the numbers corresponding to the integer “w” with the same number r1=L1*w1; r2=L2*w2; r3=L3*w3; r4=L4*w4; define formula to get total usable square feet Usable_space=(r1+r2+r3+r4); Have program show with printf command Usable square feet for each room and total usable square feet: “ The individual rooms r1-r4’s (respectively) usable area in square feet is r1,r2,r3,r4. The total usable square feet of your house with those given values is Usable_space.” END Code and run test cases. If successful code is good to go. Test case...

Words: 354 - Pages: 2

Free Essay

Cmis 102 Assignment 1

...Jeremy Lovell CMIS 102 7987 Introduction to Problem Solving and Algorithm Design (2152) Bryan Nilsen 29 March 2015 NLT: 11:59 PM Program Description: This program will calculate the total usable square feet of a house by multiplying the length of width of each room and add up the product of each room to give the total square feet. Analysis: I know to calculate square feet of a room you have to multiply the length and width. Since the house has multiple rooms to get the total square feet you have to add the square feet of each room to get the total. I decide to create the input simple by giving the variables names that are easily identifiable. L stands for Length and W stands for Width, RM stands for room which is the product of the corresponding Length and Width. Finally SgFT is the sum of all three RMs. I used these variable names to easily see within the program where I get there data values. Test Data: | Input: | Output | Test Case 1: | Room1: length=10, width=20 Room2: length=15, width=10 Room3: length=20, width=15 | Total Square Feet: 650 | Test Case 2: | Room1: length=13, width=11 Room2: length=9, width=7 Room3: length=22, width=19 | Total Square Feet: 624 | Test Case 3: | Room1: length=8, width=6 Room2: length=4, width=12 Room3: length=30, width=25 | Total Square Feet: 846 | Pseudocode: //Declare Variables Declare L1, L2, L3, W1, W2, W3, RM1, RM2, RM3 and SqFT //Set Values of Variables Set L1=10 Set L2=15 Set L3=20 Set W1=20 ...

Words: 294 - Pages: 2

Free Essay

Umuc-Cmis 102 Hw 4

...Joe Metz Professor James Huskins CMIS 102 6385 February 22nd 2015 Program Description – This program will calculate the area and perimeter of a rectangle with the provided user input. Analysis – First the user needs to provide the values for both the length and the width of the rectangle they want to determine the area and perimeter from. From there calculations need to be made. For this example we will use a rectangle with the length of 3 and a width of 9. The formula for determining the perimeter of a rectangle is P=2(l+w) where l and w stand for length and width and P is perimeter. While the formula for determining the area of a rectangle is A=lw. Where A is area and l and w are length and width. By using the values stated previously we can plug in the numbers for that formula and get 2(3+9). Simplified that's 2x12=24. To determine the area we can plug the numbers in and get A=3x9 or A=27. By writing the formulas into a function and calling that function we can have the program use any variety of input by the user to determine what the area and perimeter of a rectangle is with any values. Test Case - Test Case # | Input | Expected Output | 1 | length(l) = 3, width(w) = 9 | Perimeter (P) =24 Area (A) =27 | 2 | l = 5, w = 10 | P =30 A= 50 | 3 | l = 9, w = 36 | P=90 A= 324 | Pseudocode - //Declare Variables L, W, P, A //Float Variables P, A Write “Please Enter the Length of the Rectangle” Input...

Words: 339 - Pages: 2

Free Essay

Cmis 102 Assignment 1

...Homework 1 Program Description: The program made will perform a calculation to determine the square feet of 4 rooms in a house. It will then sum the square feet of all 4 rooms to find the total usable area of a house. Given all rooms are rectangular Analysis: The area of a room can be determined by a simple math equation of Area=Length x Width. Because we are creating a program to calculate square feet, the program will require an input and output. First thing we have to do is figure out the dimensions of the rooms. Then, we must plug in the dimensions to the appropriate variables. Afterwards, we sum all of the variables together to find the total usable area of the house. The following is the formula to determine the square feet of each room L = Length W = Width Room1 = L1 * W1 Room2 = L2 * W2 Room3 = L3 * W3 Room4 = L4 * W4 Total area = Room1+Room2+Room3+Room4 Test/Pseudo code: Test Case # | Input | Expected Output | 1 | Room1: L=12, W=12 Room2: L=10, W=11Room3: L=15, W=15Room4: L=13, W=14 | 661 square feet | 2 | Room1: L=11, W=13 Room2: L=13, W=12Room3: L=16, W=14Room4: L=11, W=11 | 644 square feet | 3 | Room1: L=13, W=12 Room2: L=13, W=13Room3: L=14, W=15Room4: L=12, W=13 | 691 square feet | Pseudo code: //this program sums the square feet of 4 rooms to determine the total usable square feet of a house //declaration of variables //declare room 1, room 2, room 3, room 4 as integer //design Set room 1 = L1*W1 Set room 2 = L2*W2 Set room 3 = L3*W3 ...

Words: 304 - Pages: 2

Free Essay

Cmis 102 Homework 1

...Program Description: This program will calculate all of the useable area (in square feet) in a house. This specific house contains four rooms, all of which are rectangular in shape. Analysis: My goal in creating this program is that it successfully calculates the useable square footage in a house that contains four rooms. The values which are required to perform the calculations will be the length of room 1 times the width of room 1(in feet). This will give the area of room one, which will in turn become the useable area for this particular room. The same length times width (L x W) formula will then be used for all subsequent rooms. After the area for all four rooms has been found, the sum of the area of each room will be the final output for useable square feet. The output values are as follows: * L1: The length for room 1 * W1: The width for room 1 * L2: The length for room 2 * W2: The width for room 2 * L3: The length for room 3 * W3: The width for room 3 * L4: The length for room 4 * W4: The width for room 4 * T1: Total square feet for room 1 * T2: Total square feet for room 2 * T3: Total square feet for room 3 * T4: Total square feet for room 4 * Total_SqFt: Total useable square footage in the house Test Plan: Test Case # | Input | Expected Output | 1 | Room 1 - Length:20 Width:14Room 2: - Length:16 Width:12Room 3: - Length:22 Width:16Room 4: - Length:12 Width:10 | Square Feet: 944 | 2 | Room 1 -...

Words: 653 - Pages: 3

Free Essay

Cmis 102 Homework 2

...Homework Assignment #2 Analysis Input: The input of this program will consist of the base price (BasePrice), the operating system choice (OSChoice), the monitor choice (MonitorChoice), and the case choice (CaseChoice). After the user has made all of the required choices, the program will determine the appropriate cost of that option: OSCost, MonitorCost, and CaseCost. Output: The required output for the program will be the total cost (TotalCost) of the state of the art gaming computer. The program will then determine the total cost of the state of the art gaming computer by using the following computation: TotalCost = BasePrice+OSCost+MonitorCost+CaseCost. Variables: BasePrice // The cost of the computer prior to the user deciding on the three options OSChoice // The operating system selected by the user Win7 // Windows 7 Home Premium Win8 // Windows 8.1 RedHat // Red Hat Linux 9.0 Personal MonitorChoice // The monitor selected by the user Asus // Asus 23.6” LED ViewSonic // ViewSonic 20” LED Acer // Acer 23” LCD CaseChoice // The case selected by the user Thermal // Thermaltake Gaming Case Rosewill // Rosewill Black Gaming Case NZXT // NZXT Guardian Gaming Case OSCost // The cost of the selected operating system MonitorCost // The cost of the selected monitor CaseCost // The cost of the selected case TotalCost // The total cost of the gaming system Design Input the base price of the computer Calculate user selected options to add the additional...

Words: 735 - Pages: 3