如何使用C#中的用户输入进行计算 [英] How to make calculations with user input in C#

查看:61
本文介绍了如何使用C#中的用户输入进行计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!



初学c#爱好者在这里。我正在上c#课程,但我的任务很困难。这里的详细信息:





hi there!

beginner c# enthusiast here. i am taking c# classes but having a difficult time with my assignment. here's details:


Create a new class called Manager that derives from your Employee class. Your Manager class will add the following functionality:                                                                     
Has a property for stock options that gets and sets the number of stock options. Use an appropriate default if a null constructor is used on your manager object.                                                                 
Adds a method that will calculate a bonus based upon a user inputted value.                                                 
Create a class named SalesAssociate that derives from your Employee class and has the following additional functionality:                                                                     
Has a property named NumberOfSales that keeps track of the monthly sales for a Sales Associate. You will need an appropriate default for this property if a null constructor is used for your Sales Associate object.                                                
Adds a method named SalesBonus that calculates a bonus 5% if a Sales Associate makes over 10 sales a month, 10% for over 20 sales, and 20% for over 30 sales per month.                    
You will need appropriate overrides to the ToString() method to print out the state information associated with your new classes.
In your Main method do the following:                    
Create a manager object with your null constructor to check for a missing data situation. 
Print out a report title that states "Data Dump Using Inline Printing".
Print out the data for this null manager object.    
Create a sales associate object with your null constructor and then print out the state information for this object. Print out your state information after creating your object.    
Print out a report title that states "Data Dump Using Polymorphism (Data Stored in a List)".
After creating your objects and printing out all of the state information associated with your object, use polymorphism by creating a List of your employee objects and then print out the appropriate state information with a foreach block.





i在我应该进行计算的部分遇到问题。任何有助于我开始的帮助表示赞赏!



我尝试过:



i只有伪代码但我在将其转换为c#时遇到了麻烦。对于大多数人来说这可能是小菜一碟,但我对c#很新,并且非常希望得到你的帮助。



i am having trouble with the part where i am supposed to make calculations. any help with getting me started is appreciated!

What I have tried:

i only have the pseudocode but i have trouble in translating that into c#. this is probably a piece of cake for most of you but i am very new to c# and would really like your help.

推荐答案

这是C#的基本示例控制台应用程序,允许您传入参数,并将解析值。我建议玩;将一些已解析的值分配给变量并从那里进行一些基本计算。

https://www.dotnetperls。 com / main [ ^ ]
Here is a basic sample of a C# Console Application that allows you to pass in arguments, and will parse out the values. I would recommend playing with; assigning some of the parsed values into variables and do some basic calculations from there.
https://www.dotnetperls.com/main[^]

这篇关于如何使用C#中的用户输入进行计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆