WINDOWS APPLICATION

sליאורה

New member
WINDOWS APPLICATION

לשעורי בית נתנו לי את התרגיל הבא : יש לכתוב תוכנית הקולטת דרגת השכלה (אחד מהערכים A,B,C,D כש-A הדרגה הנמוכה ו-D הגבוהה ביותר) וותק במקצוע (בשנים החל מאפס ועד 30). התוכנית מחשבת שכר לפי וותק ודרגת השכלה כלהלן: לבעלי וותק של 0-2 שנים משכורת של 1000 ₪ (ללא חשיבות בהשכלה) לבעלי וותק של 3-10 שנים, משכורת של 2000 ₪ + כפולות של 100 ₪ לכל דרגה (עבור A תוספת של 100 עבור B תוספת של 200 עבור C 300 ועבור D 400). לבעלי וותק של 11-20 שנה, 3000 ₪ + כפולות של 200 ₪ לכל דרגת השכלה לבעלי וותק של 21 שנה או יותר, 5000 ₪ ללא תלות בהשכלה . ברור לי איך עושים את התנאי הראשון. התנאי השני והשלישי הוא הבעייתי... איך אני קובעת את הכפולות.כל כך הרבה IF ? בבקשה עזרה דחופה -יש להגיש את השיעורים מחר.
 

Zeliran

New member
.....

בעיקרון את יכולה להשתמש בפונקציה כדי לחשב כמה תוספת להוסיף בהתאם לרמת ההשכלה.. שתשתמש בלולאה.. כלומר הקוד יכול להראות משהו כזה:
public class Form1 : System.Windows.Forms.Form { private System.Windows.Forms.Button button1; private System.Windows.Forms.TextBox year; private System.Windows.Forms.ComboBox combo; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; int temp; int salery; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.button1 = new System.Windows.Forms.Button(); this.year = new System.Windows.Forms.TextBox(); this.combo = new System.Windows.Forms.ComboBox(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(120, 136); this.button1.Name = "button1"; this.button1.TabIndex = 0; this.button1.Text = "button1"; this.button1.Click += new System.EventHandler(this.button1_Click); // // year // this.year.Location = new System.Drawing.Point(72, 80); this.year.Name = "year"; this.year.Size = new System.Drawing.Size(64, 20); this.year.TabIndex = 1; this.year.Text = ""; // // combo // this.combo.Items.AddRange(new object[] { "A", "B", "C", "D"}); this.combo.Location = new System.Drawing.Point(168, 80); this.combo.Name = "combo"; &nbsp​
 

Zeliran

New member
המשך..

לא היה מספיק מקום אז אני פשוט אוסיף את זה בקובץ טקסט נפרד.. עוד כמה דברים: בטופס יש מספר פקדים - combo - היא בעצם ComboBox בה יש את כל רמות ההשכלה year - תיבת טקסט בה המשתמש רושם את הוותק ועוד כפתור שבלחיצה עליו נעשה החישוב.. אם יש בעיה עם הקוד תגידי וננסה להסביר..
 

Zeliran

New member
אופס...

צריך לתקן את הפונקציה Raise לזה:
private int Raise(int jumper) { for(int i=0;i<combo.SelectedIndex;i++) jumper += jumper; return jumper; }​
משום מה הוספתי +1 הדוגמה הקודמת...
 

sליאורה

New member
אני לא מכירה חצי ממה שכתבת ...

אני שולחת את מה שאני יודעת - חשבתי אולי לעשות IF בתוך IF.זה לא הרבה יותר פשוט?
 
למעלה