第7题:计算半径为5的圆的面积和周长并打印出来。(pi为3.14)面积为:pirr;Perimeter(周长)
using System;
namespace 练习题7
{
class Program
{
static void Main(string[] args)
{
int r = 5;
double area = 3.14 * r * r;
double perimeter = 2 * 3.14 * r;
Console.WriteLine("圆的面积是{0},周长是{1}", area, perimeter);
Console.ReadKey();
}
}
}
第8题:某商店T恤(T-shirt)的价格为35元/件,裤子(trousers)的价格为120元/条。小明在该店买了3件T恤和2条裤子,请计算并显示小明应该付多少钱?
打8.8折后呢?
using System;
namespace 练习题8
{
class Program
{
static void Main(string[] args)
{
int T_shirt = 35;
int trousers = 120;
int totalMoney = 3 * T_shirt + 2 * trousers;
Console.WriteLine(totalMoney);
double realMoney = totalMoney * 0.88;
Console.WriteLine(realMoney);
Console.ReadKey();
}
}
}