0% found this document useful (0 votes)
3 views3 pages

Free For All

The document contains multiple C# programs that perform various calculations including bank deposit interest, acceleration, average speed, money denomination breakdown, prime number checking, carbon monoxide emissions, linear spacing of numbers, and finding maximum and minimum values from user input. Each program prompts the user for input and outputs the result based on the calculations performed. The programs demonstrate basic programming concepts such as loops, conditionals, and data types.

Uploaded by

ptct
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Free For All

The document contains multiple C# programs that perform various calculations including bank deposit interest, acceleration, average speed, money denomination breakdown, prime number checking, carbon monoxide emissions, linear spacing of numbers, and finding maximum and minimum values from user input. Each program prompts the user for input and outputs the result based on the calculations performed. The programs demonstrate basic programming concepts such as loops, conditionals, and data types.

Uploaded by

ptct
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

static void Main(string[] args)


{
double deposit,interest;
Console.Write("Enter Bank deposit : ");
deposit = Convert.ToDouble(Console.ReadLine());
interest = deposit * 0.07;
Console.WriteLine("Interest 7 percent : " + interest);
Console.WriteLine("Current deposit : " + (interest+deposit));
}

2. static void Main(string[] args)


{
double acceleretion, velocity, distance, time;
Console.Write("Enter velocity in km/hr : ");
velocity = Convert.ToDouble(Console.ReadLine());
velocity = velocity * 0.27778;
Console.Write("Enter distance s in meters : ");
distance = Convert.ToDouble(Console.ReadLine());
Console.Write("Time to take off is : ");
time = Convert.ToDouble(Console.ReadLine());
acceleretion = ((velocity*velocity)/(2.00*distance));
Console.WriteLine("Acceleration is : " + acceleretion + "m/s^2");
Console.WriteLine(" or is : " + (acceleretion /1000.00) +
"Km/s^2");
Console.WriteLine("End of program");
}

3. static void Main(string[] args)


{
double speed,distance,time;
Console.Write("What is the distance you will travel in kilometers : ");
distance = Convert.ToDouble(Console.ReadLine());
Console.Write("how many minutes do you have for travelling : ");
time = Convert.ToDouble(Console.ReadLine());
time = time * 0.016667;
speed = distance/time;
Console.WriteLine("Average speed is : " + speed + "km/hr");
if(speed>=0.00&&speed<5.00)
{
Console.WriteLine("Suggesting walking");
}
else if (speed >= 5.00 && speed < 15.00)
{
Console.WriteLine("Suggesting cycling");
}
else if (speed >= 15.00 && speed < 120.00)
{
Console.WriteLine("Suggesting car");
}
else if (speed >= 120.00)
{
Console.WriteLine("Suggesting airplane");
}
}
4. static void Main(string[] args)
{
int money,thousand,fivehundred,hundred;
Console.Write("Please input amount of money : ");
money = Convert.ToInt32(Console.ReadLine());
thousand = money / 1000;
money = money - (thousand * 1000);
fivehundred = money / 500;
money = money - (fivehundred * 500);
hundred = money / 100;
Console.WriteLine("B1000 = " + thousand);
Console.WriteLine("B500 = " + fivehundred);
Console.WriteLine("B100 = " + hundred);
}

5. static void Main(string[] args)


{
bool prime = true;
int[] input = new int[3];
string[] buffer;
Console.Write("Input : ");
buffer = Console.ReadLine().Split(' ');
for (int i = 0; i <= 2; i++)
{
input[i] = Convert.ToInt32(buffer[i]);
}
Console.WriteLine();
for (int i = 2; i < input[1]; i++)
{
if (input[1] % i == 0&&input[1]!=2)
{
prime = false;
}
else if(input[1]==2)
{
break;
}
}
Console.Write("Output : " + input[1]);
if(prime==true)
{
Console.WriteLine(" is prime");
}
else
{
Console.WriteLine(" is not prime");
}
}

6. static void Main(string[] args)


{
int vehiclecount;
Console.Write("Enter the number of vehicles> ");
vehiclecount = Convert.ToInt32(Console.ReadLine());
double[] miles = new double[vehiclecount];
double[] emittedcarbon = new double[vehiclecount];
double[] calculation = new double[vehiclecount];
Console.WriteLine();
for (int i = 0; i <= vehiclecount; i++)
{
Console.Write("Enter amount of carbon monoxide emitted (grams)> ");
emittedcarbon[i] = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter miles driven> ");
miles[i] = Convert.ToDouble(Console.ReadLine());
calculation[i] = emittedcarbon[i] / miles[i];
Console.Write("Carbon monoxide emission of "+calculation[i] + "g/mi
");
if (calculation[i] > 3.40)
{
Console.WriteLine("exceeds permitted emission of 3.4 g/mi.\n");
}
else
{
Console.WriteLine("meets permitted emission of 3.4 g/mi.\n");
}
}
}

7. static void Main(string[] args)


{
int max,min,space;
Console.Write("Input the maximum number = ");
max = Convert.ToInt32(Console.ReadLine());
Console.Write("Input the minimum number = ");
min = Convert.ToInt32(Console.ReadLine());
Console.Write("Input the number of linearly spaced points = ");
space = Convert.ToInt32(Console.ReadLine());
Console.Write("OUTPUT : ");
space = (max - min) / space;
for(int i=min;i<=max;i+=space)
{
Console.Write(" "+i);
}
}

8. static void Main(string[] args)


{
int[] number = new int[10];
int max, min;
for (int i = 0; i <= 9; i++)
{
Console.Write("Please enter the number : ");
number[i] = Convert.ToInt32(Console.ReadLine());
}
max = number[0];
min = number[0];
for (int i = 0; i <= 9; i++)
{
if(number[i]>max)
{
max = number[i];
}
else if(number[i]<min)
{
min = number[i];
}
}
Console.WriteLine("The maximum number is " + max + " and the minimum
number is " + min);

You might also like