Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Namespace Lecture 4 1
{
Class Program
{
Static void Main (string [] args)
{
Console. Write (10/3*1.0 );
Decimal PI = 3.14 m;
Double pi = (double) PI;
Console. ReadKey ();
Int TX = 35;
Int KZ = 50;
Int sum = TX * 3 + KZ * 2;
Int pay = (int) (sum * 0.88 );
Console. Write (10/3*1.0 );
// 1. Ask the user to enter the name of a student and the score of the three homework. Then, calculate the total score and average score of the student through the program and enter the score. The total score of Xxx is xxx, and the average score is xxx.
// How can I prevent user input errors?
Try
{
Console. Write ("Enter the Student name :");
String name = Console. ReadLine (); // receives user input
Console. Write ("Enter the mathematical score :");
Int math = Convert. ToInt32 (Console. ReadLine ());
Console. Write ("enter Chinese score :");
Int chinese = Convert. ToInt32 (Console. ReadLine ());
Console. Write ("Enter the English score :");
Int english = Convert. ToInt32 (Console. ReadLine ());
Console. writeLine ("the total score of the three courses in {0} is {1}, and the average score is {2}", name, math + chinese + english, (math + chinese + english) /3 );
}
Catch {
Console. WriteLine ("the score you entered is incorrect. Please enter a positive integer within 100. ");
}
// 2. Programming implementation: If you enter a day (for example, 46 days), the program calculates the number of weeks and days. And output in the console
Console. WriteLine ("Enter the number of days :");
Int days = Convert. ToInt32 (Console. ReadLine ());
Int weeks = days/7;
Int day = days % 7;
Console. WriteLine ("{0} days: {1} day of the week (0)", days, weeks, day );
// 3. The number of seconds (10765326878657 seconds) input by the user is calculated as several days, several hours, and several seconds.
Console. WriteLine ("Please enter the number of seconds :");
Int seconds = Convert. ToInt32 (Console. ReadLine ());
Int days = seconds/(24x3600 );
Int mod = seconds % (3600*24); // get the remaining number of seconds beyond the number of seconds in the previous day
Int houres = mod/3600; // The number of 3600 seconds in the second, that is, the number of hours.
Mod = mod % 3600; // obtain the number of seconds remaining for the previous hour in the remaining number of seconds.
Int min = mod/60; // obtain the number of 60 seconds in the remaining seconds, that is, the number of minutes.
Int second = mod % 60;
Console. WriteLine ("{0} seconds include {1} Days, {2} hours, {3} minutes, {4} seconds. ", Seconds, days, houres, min, second );
// 4. Use a computer to describe the result of this sentence.
Int zsAge = 20;
Int lsAge = 18;
Bool isRright = zsAge! = LsAge;
Console. WriteLine (isRright );
Console. ReadKey ();
}
}
}