• 学分绩点计算器


    using System;
    using System.Collections.Generic;
    using System.Text;
    
    namespace 西南石油大学_学分绩点计算器
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("西南石油大学--学分绩点计算器");
                Console.WriteLine();
    
                Term thisTerm = new Term();
                int NumOfCourses = GetInput.CourseNum();//本学期课程数
    
                for (int i = 1; i <= NumOfCourses; i++)
                {
                    Console.WriteLine();
                    Console.WriteLine("--------------开始录入第{0}门课程--------------", i);
    
                    Console.WriteLine("第{0}门课程有几个学分?", i);
    
                    double credit = GetInput.GetCredit();
    
                    Console.WriteLine("第{0}门课程考了多少分?", i);
    
                    double score = GetInput.GetCredit();
    
                    Course OneCourse = new Course(credit, score);
    
                    thisTerm.AddOneCourse(OneCourse);
    
                    Console.WriteLine("--------------第{0}门课程录入完毕--------------", i);
                    Console.WriteLine();
                }
    
                Console.WriteLine("最后学分绩点是:" + thisTerm.GetFinalJIDIAN());
                Console.WriteLine("欢迎访问我的博客:http://blog.csdn.net/cuipengfei1");
                Console.Read();
                System.Diagnostics.Process.Start("http://blog.csdn.net/cuipengfei1");
    
            }
        }
    
        class GetInput
        {
            public static int CourseNum()
            {
                Console.WriteLine("本学期一共有几门必修课程?(注意,是必修课程哦)");
                string num = Console.ReadLine();
                int NUM;
                int.TryParse(num, out NUM);
                return NUM;
            }
    
            public static double GetCredit()
            {
                string credit = Console.ReadLine();
                double CREDIT;
                double.TryParse(credit, out CREDIT);
                return CREDIT;
            }
    
        }
    
        class Course//一门课程
        {
            private double credit;//学分
    
            private double score;//分数
    
            public double Credit//学分
            {
                get { return credit; }
                set { credit = value; }
            }
    
    
            public double Score//分数
            {
                get { return score; }
                set { score = value; }
            }
    
            public Course(double _credit, double _score)//构造
            {
                credit = _credit;
                score = _score;
            }
    
            public double GetJIDIAN() //本门绩点
            {
                double jidian;
                jidian = ((score - 60) / 10) + 1;
                return jidian;
            }
        }
    
        class Term //本学期
        {
            List<Course> AllCourse = new List<Course>();
    
            public void AddOneCourse(Course course)
            {
                AllCourse.Add(course);
            }
    
            public double GetFinalJIDIAN()
            {
                double totalCredit = 0;
    
                double totalJIDIAN = 0;
    
                foreach (Course oneCourse in AllCourse)
                {
                    totalCredit += oneCourse.Credit;
                    totalJIDIAN += oneCourse.GetJIDIAN() * oneCourse.Credit;
                }
    
                return totalJIDIAN / totalCredit;
            }
        }
    }
  • 相关阅读:
    DWR3.0 如何应用的简单介绍(有实例)
    细线表格样式
    myeclipse不编译解决方法
    DORADO中resoler&dataProvider的常用方法
    jBPM插件下载地址及jBPM配置视频
    dorado要点总结
    千万级数据库(MSSQL)删除重复记录
    Dorado 7 IDE下载地址
    WIN CE和电脑之间的文件拷贝(2) Form1.cs文件
    获取所有存储过程源码替换存储过程方法
  • 原文地址:https://www.cnblogs.com/l25321937/p/4994704.html
Copyright © 2020-2023  润新知