306(基础回顾)接受用户输入的两个数(分两次),将这两个数求和并显示结果。
307.编写一个程序,输入两个数,将其由大到小的顺序输出。
308.编写一个程序,由用户输入身高(high厘米)和体重(weight公斤),
根据所输数值,计算下列公式的值:
K=(身高-体重)×0.7
当k>80,输出一句话:你的体重过胖
当k<80,输出一句话:你的体重过瘦
-------------------------------------------------------------------------- 306: using System;
class Addition
{
static void Main()
{
// 定义两个字符串类型的变量,用来接受用户输入
string firstNumber, secondNumber;
// 定义三个整形类型的变量,用来将字符串转换成整形进行计算与求和
int number1, number2, sum;
// 输出一句话,提示用户
Console.Write( "Please enter the first integer: " );
firstNumber = Console.ReadLine();// 接受第一个字符串
//再输出一句话,提示用户
Console.Write( "\nPlease enter the second integer: " );
secondNumber = Console.ReadLine();// 接受第一个字符串
// 将其转换成整形
number1 = Int32.Parse( firstNumber );
number2 = Int32.Parse( secondNumber );
// 相加并赋给sum
sum = number1 + number2;
// 显示结果
Console.WriteLine( "\nThe sum is {0}.", sum );
} // end method Main
} // end class Addition ---------------------------------------------------------------------------------- 307 using System;
class A307 {
static void Main()
{
string firstNumber, secondNumber;
int number1, number2;
Console.Write( "Please enter the first integer: " );
firstNumber = Console.ReadLine();
Console.Write( "\nPlease enter the second integer: " );
secondNumber = Console.ReadLine();
number1 = Int32.Parse( firstNumber );
number2 = Int32.Parse( secondNumber );
if(number1>mumber2)
{ Console.WriteLine(number1+";"+number2); } else
Console.WriteLine(number2+";"+number1 );
}
} -------------------------------------------------------------------------------- 308: using System;
class Gongshi
{
static void Main()
{
string high, weight ;
double n1,n2 ,m,k3;
Console.Write( "Please enter you high: " );
high= Console.ReadLine();
Console.Write( "\nPlease enter you weight: " ); weight= Console.ReadLine();
n1=Int32.Parse(high); n2=Int32.Parse(weight); k3=(n1-n2)*0.7; if(k3>80) { Console.WriteLine("你的身体过胖"); } else
Console.WriteLine( "你的身体过艘瘦", k3 );
}
}
-------------------------------------------------------------------- 以前天天问题今天终于发拉个。