Free Essay

Cmis 102 Hw 1

In:

Submitted By daemonkieran
Words 945
Pages 4
Student Name, CMIS102, Professor Name
Due Date: 21SEP2014

Calculating the usable square feet of up to four rooms

Program Description - This program is designed to calculate the usable square feet of up to four rooms. It asks for an input for the number of rooms and the length and width of each room in feet. It then outputs in a readable format the sqft of each room and the total usable square feet. I also attempted to write the program in C at the bottom.

Analysis - For this program I wanted to be able to calculate the exact number of usable square feet of up to four rooms without asking for unnecessary inputs so I decided to go with an if statement format. I decided I would need the number of rooms, length, and width of each room from the user. The formula for square feet (length * width).

Variables - number_of_rooms, room1_l, room1_w, room1_sqft, room2_l, room2_w, room2_sqft, room3_l, room3_w, room3_sqft, room4_l, room4_w, room4_sqft, total Testing -

test1 2,10,10,12,3 "The square footage of room 1 is 100" "The square footage of room 2 is 36" "The total usable square footage of the house is 136"

test2 1,4,5 "The square footage of room 1 is 20"

test3 6.2,3,24,00001,222 error

Psuedocode

main input number_of_rooms if number_of_rooms is 1 input room1_l input room1_w compute room1_sqft as room1_l * room1_w write "The square footage of room 1 is"room1_sqft"\n" else if number_of_rooms is 2 input room1_l input room1_w input room2_l input room2_w compute room1_sqft as room1_l * room1_w compute room2_sqft as room2_l * room2_w compute total as room1_sqft + room2_sqft write "The square footage of room 1 is"room1_sqft"\n" write "The square footage of room 2 is"room2_sqft"\n" write "The total usable square footage of the house is "total"\n" else if number_of_rooms is 3 input room1_l input room1_w input room2_l input room2_w input room3_l input room3_w compute room1_sqft as room1_l * room1_w compute room2_sqft as room2_l * room2_w compute room3_sqft as room3_l * room3_w compute total as room1_sqft + room2_sqft + room3_sqft write "The square footage of room 1 is"room1_sqft"\n" write "The square footage of room 2 is"room2_sqft"\n" write "The square footage of room 3 is"room3_sqft"\n" write "The total usable square footage of the house is "total"\n" else if number_of_rooms is 4 input room1_l input room1_w input room2_l input room2_w input room3_l input room3_w input room4_l input room4_w compute room1_sqft as room1_l * room1_w compute room2_sqft as room2_l * room2_w compute room3_sqft as room3_l * room3_w compute room4_sqft as room4_l * room4_w compute total as room1_sqft + room2_sqft + room3_sqft + room4_sqft write "The square footage of room 1 is"room1_sqft"\n" write "The square footage of room 2 is"room2_sqft"\n" write "The square footage of room 3 is"room3_sqft"\n" write "The square footage of room 4 is"room4_sqft"\n" write "The total usable square footage of the house is "total"\n" end if number_of_rooms is >4 end #include <stdio.h>

main()
{

int number_of_rooms, room1_w,room1_l, room1_sqft, room2_w, room2_l, room2_sqft, room3_w, room3_l, room3_sqft, room4_w, room4_l, room4_sqft, total;

printf("Enter the number of rooms\v");

scanf("%d", number_of_rooms);

if (number_of_rooms == 1) {

printf("Enter the width of Room 1\n");

scanf("%d", room1_w);

printf("Enter the length of Room 1\n\n");

scanf("%d", room1_l);

room1_sqft = room1_w * room1_l;

total = room1_sqft;

printf("Room 1 is %d square feet\n", room1_sqft);

printf("The total usable square feet is %d", total);

return 0;

}

else if (number_of_rooms == 2)

{ printf("Enter the width of Room 1\n");

scanf("%d", room1_w);

printf("Enter the length of Room 1\n\n");

scanf("%d", room1_l);

room1_sqft = room1_w * room1_l;

printf("Enter the width of Room 2\n");

scanf("%d", room1_w);

printf("Enter the length of Room 2\n\n");

scanf("%d", room2_l);

room2_sqft = room2_w * room2_l;

total = room1_sqft + room2_sqft;

printf("Room 1 is %d square feet\n", room1_sqft);

printf("Room 2 is %d square feet\n", room2_sqft);

printf("The total usable square feet is %d", total);

return 0;

}

else if (number_of_rooms == 3)

{ printf("Enter the width of Room 1\n");

scanf("%d", room1_w);

printf("Enter the length of Room 1\n\n");

scanf("%d", room1_l); room1_sqft = room1_w * room1_l;

printf("Enter the width of Room 2\n");

scanf("%d", room1_w); printf("Enter the length of Room 2\n\n"); scanf("%d", room2_l);

room2_sqft = room2_w * room2_l;

printf("Enter the width of Room 3\n"); scanf("%d", room3_w);

printf("Enter the length of Room 3\n\n");

scanf("%d", room3_l);

room3_sqft = room3_w * room3_l;

total = room1_sqft + room2_sqft + room3_sqft;

printf("Room 1 is %d square feet\n", room1_sqft);

printf("Room 2 is %d square feet\n", room2_sqft);

printf("Room 3 is %d square feet\n", room3_sqft);

printf("The total usable square feet is %d", total);

return 0;

}

else if (number_of_rooms == 4)

{ printf("Enter the width of Room 1\n");

scanf("%d", room1_w);

printf("Enter the length of Room 1\n\n");

scanf("%d", room1_l);

room1_sqft = room1_w * room1_l;

printf("Enter the width of Room 2\n");

scanf("%d", room1_w);

printf("Enter the length of Room 2\n\n");

scanf("%d", room2_l);

room2_sqft = room2_w * room2_l;

printf("Enter the width of Room 3\n");

scanf("%d", room3_w);

printf("Enter the length of Room 3\n\n");

scanf("%d", room3_l);

room3_sqft = room3_w * room3_l;

printf("Enter the width of Room 4\n");

scanf("%d", room4_w);

printf("Enter the length of Room 4\n\n");

scanf("%d", room4_l);

room3_sqft = room4_w * room4_l;

total = room1_sqft + room2_sqft + room3_sqft + room4_sqft;

printf("Room 1 is %d square feet\n", room1_sqft);

printf("Room 2 is %d square feet\n", room2_sqft);

printf("Room 3 is %d square feet\n", room3_sqft);

printf("Room 4 is %d square feet\n", room4_sqft);

printf("The total usable square feet is %d", total);

return 0;

}

}

Similar Documents

Free Essay

Concrete

...AS 3600—2009 AS 3600—2009 Australian Standard® Concrete structures Accessed by NEWCREST MINING LIMITED on 14 Jul 2010 This Australian Standard® was prepared by Committee BD-002, Concrete Structures. It was approved on behalf of the Council of Standards Australia on 8 October 2009. This Standard was published on 23 December 2009. The following are represented on Committee BD-002: • • • • • • • • • • • • • • • • AUSTROADS Association of Consulting Engineers Australia Australian Building Codes Board Bureau of Steel Manufacturers of Australia Cement Concrete & Aggregates Australia—Cement Cement Concrete & Aggregates Australia—Concrete Concrete Institute of Australia Engineers Australia La Trobe University Master Builders Australia National Precast Concrete Association Australia Steel Reinforcement Institute of Australia University of Adelaide University of Melbourne University of New South Wales University of Western Sydney This Standard was issued in draft form for comment as DR 05252. Standards Australia wishes to acknowledge the participation of the expert individuals that contributed to the development of this Standard through their representation on the Committee and through the public comment period. Keeping Standards up-to-date Accessed by NEWCREST MINING LIMITED on 14 Jul 2010 Australian Standards® are living documents that reflect progress in science, technology and systems. To maintain their currency, all Standards are periodically reviewed, and...

Words: 70634 - Pages: 283

Premium Essay

Work, Culture and Identity in Mozambique and Southafrica 1860-1910

...Acknowledgments ix Acknowledgments This book owes a great deal to the mental energy of several generations of scholars. As an undergraduate at the University of Cape Town, Francis Wilson made me aware of the importance of migrant labour and Robin Hallett inspired me, and a generation of students, to study the African past. At the School of Oriental and African Studies in London I was fortunate enough to have David Birmingham as a thesis supervisor. I hope that some of his knowledge and understanding of Lusophone Africa has found its way into this book. I owe an equal debt to Shula Marks who, over the years, has provided me with criticism and inspiration. In the United States I learnt a great deal from ]eanne Penvenne, Marcia Wright and, especially, Leroy Vail. In Switzerland I benefitted from the friendship and assistance of Laurent Monier of the IUED in Geneva, Francois Iecquier of the University of Lausanne and Mariette Ouwerhand of the dépurtement évangélrlyue (the former Swiss Mission). In South Africa, Patricia Davison of the South African Museum introduced me to material culture and made me aware of the richness of difference; the late Monica Wilson taught me the fundamentals of anthropology and Andrew Spiegel and Robert Thornton struggled to keep me abreast of changes in the discipline; Sue Newton-King and Nigel Penn brought shafts of light from the eighteenthcentury to bear on early industrialism. Charles van Onselen laid a major part of the intellectual foundations on...

Words: 178350 - Pages: 714