美文网首页
20181107作业

20181107作业

作者: 楚荷音 | 来源:发表于2018-11-07 09:12 被阅读0次


作业1

让用户输入姓名,然后显示出这个人上辈子是什么职业。(老杨,老苏,老邹,老马,老虎,老牛,老蒋,小杨)

代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入姓名");
string name=Console.ReadLine();
switch (name)
{
case "老杨":
Console.WriteLine("老杨上辈子是折翼的天屎");
break;
case "老苏":
Console.WriteLine("老苏上辈子是老鸨子");
break;
case "老邹":
Console.WriteLine("老邹上辈子是老苏手下的头牌");
break;
case "老马":
Console.WriteLine("上辈子是个是个地主");
break;
case "老虎":
Console.WriteLine("上辈子被武松挂了");
break;
case "老牛":
Console.WriteLine("上辈子是Cow");
break;
case "老蒋":
Console.WriteLine("上辈子是个秀才");
break;
case "小杨":
Console.WriteLine("上辈子是妖");
break;
default:
Console.WriteLine("上辈子没这个人");
break;
}

        Console.ReadKey();

    }
}

}


效果


image.png


作业2

请用户输年份,再输入月份,输出该月的天数.

代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入年份");

        int year = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("请输入月份");

        int month = Convert.ToInt32(Console.ReadLine());
        if (month >= 1 && month <= 12)
        {
            int day=0;
            switch (month)
            {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    day = 31;
                    break;
                case 4:
                case 6:
                case 9:
                case 11:
                    day = 30;
                    break;
                case 2:
                    if (year % 4 == 0)
                        day = 29;
                    else
                        day = 28;
                    break;
              
            }
            Console.WriteLine("{0}年{1}月有{2}天", year, month, day);
        }
        else
            Console.WriteLine("月份必须在1-12月之间,程序退出");
        Console.ReadKey();
    }
   

    }

}

效果


image.png


作业3

某人新开一个账户,输入开始存入的金额(本金)、年利率以及存款周期(年)。假定所有的利息收入都重新存入新户,请编写程序,计算并输出在存款周期中每年年终的账面金额。计算公式如下
a=p(1+r)n
p:本金,r:年利率,n:年数,a是在第n年年终的账面金额。

代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp21
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入本金");
int p = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请输入年利率");
double r = Convert.ToDouble (Console.ReadLine());
Console.WriteLine("请输入存款年数");
int n = Convert.ToInt32(Console.ReadLine());
double a;
a = p *Math.Pow (1 + r,n);
Console.WriteLine("{0}元{1}的年利率存{2}年后年终的账面金额是{3}",p,r,n,a);
Console.ReadKey();

    }
}

}


效果


image.png

….

相关文章

  • 20181107作业

    …作业1…让用户输入姓名,然后显示出这个人上辈子是什么职业。(老杨,老苏,老邹,老马,老虎,老牛,老蒋,小杨)…代...

  • 手残党学画画003

    20181107 立冬

  • 20181107-Day13作业:

    1、你和孩子看了哪些好电影? 《三傻大闹好莱坞》《我不是药神》 2、从中收获了哪些影响? 《三傻大闹好莱坞》印象中...

  • 2018-11-08

    20181107作业: 1、你和孩子看了哪些好电影?功夫熊猫,成龙历险记,圆梦巨人,神偷奶爸,疯狂原始人,熊出没系...

  • 20181107-1

    20181107-1 今天晚上哥哥自己做作业,我带了弟弟下楼玩。6点钟时做完作业也下楼玩了一会,回家吃完饭按我们昨...

  • 亲子日记(521)

    20181107星期三 天气多云转晴 自从 买了滑板车以后,胥怡戎的最爱就是滑板车了,放了学做了作业,第一...

  • 2018-11-7

    20181107作业: 1、你和孩子看了哪些好电影? 说实话,听了蒋老师的微课,真的很惭愧,和儿子共同看的电影真的...

  • 【佳作欣赏】20181107作业雨点评

    尹璐【文章标题】完美的困惑【文章链接】https://www.jianshu.com/p/761b1e34b910...

  • 20181107

    5 “学生在寝室小便”的思考: 我们的老老老祖先穿上了衣服,踏出了人类历史进程的第一步,迈向了文明;厕所...

  • 20181107

    Day2: 西江~车上~凯里非遗馆(苗族文化+银饰)~车上~贵阳花果园(密集恐惧症要犯了,喜欢开阔的,不推荐你入住...

网友评论

      本文标题:20181107作业

      本文链接:https://www.haomeiwen.com/subject/mbdmxqtx.html