CHAPTER 2 : Variables and Data Types
using System;
namespace atlantiscientificsystems
{
class Program
{
static void Main(string[] args)
{
double minTemp;
double maxTemp;
double avgTemp;
int populationtown;
int populationstate;
bool metropolis;
float literacypercent;
string avgqualification;
[Link]("Enter the minimum temperature");
minTemp = [Link]([Link]());
[Link]("The minimum temperature is :" + minTemp+ " C");
[Link]();
[Link]("Press enter to continue");
[Link]();
[Link]("Enter the maximum temperature");
maxTemp = [Link]([Link]());
if (maxTemp < minTemp)
{
[Link]("ERROR - Please enter valid maximum temperature");
}
else
{
[Link](" The maximum temperature is :" + maxTemp + " C");
}
[Link]();
[Link]("Press enter to continue");
[Link]();
[Link]("Enter the average temperature");
avgTemp = [Link]([Link]());
[Link]("The average temperature is :" + avgTemp +"C");
[Link]();
[Link]("Press enter to continue");
[Link]();
[Link]("Enter the population of the town");
populationtown = Convert.ToInt32([Link]());
[Link]("The population of the town is :" + populationtown);
[Link]();
[Link]("Press enter to continue");
[Link]();
[Link]("Enter the population of the state");
populationstate = Convert.ToInt32([Link]());
[Link]("The population of the state is :" + populationstate);
[Link]();
[Link]("Press enter to continue");
[Link]();
[Link]("Is the city a metropolis? :");
metropolis = [Link]([Link]());
if (metropolis == true)
{
[Link]("The city is a metropolis");
}
else if (metropolis == false)
{
[Link]("The city is not a metropolis");
}
else
{
[Link]("Invalid");
}
[Link]();
[Link]("Press enter to continue");
[Link]();
[Link]("Enter the average literacy percentage");
literacypercent = [Link]([Link]());
[Link]("The average literacy percentage is :" + literacypercent+
"%");
[Link]();
[Link]("Press enter to continue");
[Link]();
[Link]("Enter the average qualification - Graduate /
PostGraduate");
avgqualification = [Link]();
[Link]("The average qualification is :" + avgqualification);
[Link]("Press enter to continue");
[Link]();
[Link]();
} } }
OUTPUT:
using System;
namespace garciainfosystems
{
class Program
{
static void Main(string[] args)
{
string Studentname, Address, Fathersname, Mothername, FathersOccupation,
MajorSubject, StudentGrade, Division;
int Studentage, Dateofbirth;
char c;
char G;
[Link]("Enter student name:");
Studentname = [Link]();
[Link]("Press enter to proceed");
[Link]();
[Link]();
[Link]("Are you a male or female? ( PLEASE ENTER [ M/F ] )");
G = [Link]([Link]());
if (G == 'M' || G == 'm')
{
[Link]("GENDER = MALE");
}
else if (G == 'F' || G == 'f')
{
[Link]("GENDER = FEMALE");
}
else
{
[Link]("INVALID");
}
[Link]("Press enter to proceed");
[Link]();
[Link]();
[Link]("Enter Address:");
Address = [Link]();
[Link]("Press enter to proceed");
[Link]();
[Link]();
[Link]("Enter Father's name:");
Fathersname = [Link]();
[Link]("Press enter to proceed");
[Link]();
[Link]();
[Link]("Enter Mother's name:");
Mothername = [Link]();
[Link]("Press enter to proceed");
[Link]();
[Link]();
[Link]("Enter Fathers Occupation:");
FathersOccupation = [Link]();
[Link]("Press enter to proceed");
[Link]();
[Link]();
[Link]("Are you a citizen or not [ Y/N ]");
c = [Link]([Link]());
if (c == 'Y' || c == 'y')
{
[Link](Studentname + " is a citizen");
}
else
{
[Link](Studentname + " is not a citizen");
}
[Link]("Press enter to proceed");
[Link]();
[Link]();
[Link]("Major Subject:");
MajorSubject = ([Link]());
[Link]("Press enter to proceed");
[Link]();
[Link]();
[Link]("Enter Age:");
Studentage = Convert.ToInt32([Link]());
[Link]("Press enter to proceed");
[Link]();
[Link]();
[Link]("Enter Date of birth {dd/MM/yyyy}");
Dateofbirth = Convert.ToInt32([Link]());
[Link]("Press enter to proceed");
[Link]();
[Link]();
[Link]("Enter Student grade");
StudentGrade = [Link]();
[Link]("Press enter to proceed");
[Link]();
[Link]();
[Link]("ENter Student Division");
Division = [Link]();
[Link]("Press enter to proceed");
[Link]();
[Link]();
[Link](Studentname + ("\u0020") + Fathersname + ("\u0020") + "
DETAILS:");
[Link]();
[Link](" Student name : {0} \n Address : {1} \n Father's name :
:{2} \n Mothers name : {3} \n Father's Occupation : {4} \n Major subject
:{5} \n Student grade : {6} \n Division :{7}", Studentname, Address,
Fathersname, Mothername, FathersOccupation, MajorSubject, StudentGrade,
Division);
[Link](" Student age: {0} \n Date of birth : {1} ", Studentage,
Dateofbirth);
[Link](" Citizen or not (Y/y = YES) (N/n = NO)", Studentname,
c);
[Link](" Male of Female? {0}", Studentname, G);
[Link]("Enter any key to continue");
[Link]();
}
}
}
CHAPTER 3: Statements and Operators