using System;
class building
{
public int floors; //number of floors //C# class doesn't support 'public :'
public int area; //total square footage of building
public int occupants; //number of occupants
}
class building_Demo
{
public static void Main()
{
building house = new building(); //create a bbuilding object
int areaPP; //area per person
//assign values to fields to fields in house
house.occupants = 4;
house.area = 2500;
house.floors = 2;
//compute the area per person
areaPP = house.area/house.occupants;
Console.WriteLine("house has:\n "+
house.floors + " floors\n "+
house.occupants + " occupants\n "+
house.area + " total area\n "+
areaPP + " area per person");
}
}
OUTPUT:
house has:
2 floors
4 occupants
2500 total area
625 area per person
class building
{
public int floors; //number of floors //C# class doesn't support 'public :'
public int area; //total square footage of building
public int occupants; //number of occupants
}
class building_Demo
{
public static void Main()
{
building house = new building(); //create a bbuilding object
int areaPP; //area per person
//assign values to fields to fields in house
house.occupants = 4;
house.area = 2500;
house.floors = 2;
//compute the area per person
areaPP = house.area/house.occupants;
Console.WriteLine("house has:\n "+
house.floors + " floors\n "+
house.occupants + " occupants\n "+
house.area + " total area\n "+
areaPP + " area per person");
}
}
OUTPUT:
house has:
2 floors
4 occupants
2500 total area
625 area per person
No comments:
Post a Comment