wallarea = (heigh * width) * 2 + (heigh * length) * 2;
double a;
double b;
double c;
double d;
double e;
a = 100;
b = 34;
c = 60;
heigth = b;
width = c;
length = a;
wallarea = e;
ceilingarea = d;
mojo1948 wrote:At first glance your height variable is spelled wrong.<br>
- Code: Select all
wallarea = (heigh * width) * 2 + (heigh * length) * 2;
double height;
double lenght;
double etc;
height = 123;
lenght=456;
int a,b,c,d,e,height,width,lenght,etc;
if (length==width)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace area_calc
{
class Program
{
static void Main(string[] args)
{
#region :: Variables ::
// wall variables
double wallHeight, shortWallWidth, longWallWidth;
// ceiling variables
double ceilLength, ceilWidth;
// area variables
double totalArea, longWallArea, shortWallArea, ceilArea;
// volumne variables
double roomVolumne;
#endregion
Console.WriteLine("Area calculator!\r\n================\n\n");
Console.Write("Please enter the height of the walls: ");
// user to input value of wallHeight...
wallHeight = Convert.ToDouble(Console.ReadLine());
Console.Write("Please enter the width of the longest walls: ");
// ... likewise for the width of the longest wall...
longWallWidth = Convert.ToDouble(Console.ReadLine());
Console.Write("Please enter the width of the shortest walls: ");
// ... and the shortest...
shortWallWidth = Convert.ToDouble(Console.ReadLine());
/*
* Assign the ceiling variables based on the values obtained for the walls
* This (foolishly) assumes that the ceiling wants to fit on the room...
*/
ceilLength = longWallWidth;
ceilWidth = shortWallWidth;
// set area variables
// 2 wall heights by 2 wall widths...
longWallArea = ((longWallWidth * wallHeight ) * 2);
// ... same for the short walls
shortWallArea = ((shortWallWidth * wallHeight ) * 2);
// area of the ceiling
ceilArea = (ceilLength * ceilWidth);
// total area of all four walls, plus the ceiling AND the floor (hence ceilArea * 2)
totalArea = longWallArea + shortWallArea + ( ceilArea * 2 );
// the room volumne, for the hell of it
roomVolumne = longWallWidth * shortWallWidth * wallHeight;
// check if the width of both walls and the ceiling match...
// ... and then print out the rest of the data as needed
if ((longWallWidth == shortWallWidth) && (longWallWidth == wallHeight))
{
Console.WriteLine("You appear to be designing a cube!");
Console.WriteLine("The area of one of your walls is: {0}", longWallArea / 2);
Console.WriteLine("The area of all your walls is: {0}", shortWallArea + longWallArea);
}
else
{
Console.WriteLine("The area of both of the longest walls is: {0}", longWallArea);
Console.WriteLine("The area of both of the shortest walls is: {0}", shortWallArea);
}
Console.WriteLine("The area of the ceiling is: {0}", ceilArea);
Console.WriteLine("Total area: {0}", totalArea);
Console.WriteLine("The volumne of the room is: {0}", roomVolumne);
Console.ReadLine();
}
}
}
Users browsing this forum: No registered users and 0 guests