Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C# I have the following Assignment. I believe I am close, but I am having trouble with passing the method arguments into the main

In C# I have the following Assignment. image text in transcribed

I believe I am close, but I am having trouble with passing the method arguments into the main program to display in the label.

This is the code I have so far:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;

namespace Lab4_Part1_GradeEntry_CRupe { public partial class StudentGrades : Form { public StudentGrades() { InitializeComponent(); }

private void BtnValidate_Click(object sender, EventArgs e) { //declare a variable for grade integer int grade = Convert.ToInt32(TxtScore.Text); // run each method CheckGrade(); AssignGrade(); GradeMessage(); //Display result to user LblMessage.Text = ToString(DisplayMessage);

} private void CheckGrade() { //Convert entered number to integer and check if valid entry int grade = Convert.ToInt32(TxtScore.Text); if (grade 100) LblMessage.Text = "User must have a successful entry to proceed"; else return;

} private void AssignGrade() { //Declare a null string and interpret result string message = ""; int grade = Convert.ToInt32(TxtScore.Text); if (grade = 60 & grade = 70 & grade = 80 & grade = 90) message = "Grade is A"; return; } private string GradeMessage(string message) { //Display result to user string DisplayMessage = ""; DisplayMessage = "You Entered an" +Convert.ToInt32(TxtScore.Text) + message; return DisplayMessage; } }

}

The designer Code is: namespace Lab4_Part1_GradeEntry_CRupe { partial class StudentGrades { ///

/// Required designer variable. ///

private System.ComponentModel.IContainer components = null;

///

/// Clean up any resources being used. ///

///true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }

#region Windows Form Designer generated code

///

/// Required method for Designer support - do not modify /// the contents of this method with the code editor. ///

private void InitializeComponent() { this.LblScore = new System.Windows.Forms.Label(); this.LblMessage = new System.Windows.Forms.Label(); this.TxtScore = new System.Windows.Forms.TextBox(); this.BtnValidate = new System.Windows.Forms.Button(); this.SuspendLayout(); // // LblScore // this.LblScore.AutoSize = true; this.LblScore.Location = new System.Drawing.Point(44, 60); this.LblScore.Name = "LblScore"; this.LblScore.Size = new System.Drawing.Size(74, 13); this.LblScore.TabIndex = 0; this.LblScore.Text = "Score (0-100):"; // // LblMessage // this.LblMessage.AutoSize = true; this.LblMessage.Location = new System.Drawing.Point(85, 117); this.LblMessage.Name = "LblMessage"; this.LblMessage.Size = new System.Drawing.Size(13, 13); this.LblMessage.TabIndex = 1; this.LblMessage.Text = "+"; // // TxtScore // this.TxtScore.Location = new System.Drawing.Point(145, 57); this.TxtScore.Name = "TxtScore"; this.TxtScore.Size = new System.Drawing.Size(100, 20); this.TxtScore.TabIndex = 2; // // BtnValidate // this.BtnValidate.Location = new System.Drawing.Point(301, 55); this.BtnValidate.Name = "BtnValidate"; this.BtnValidate.Size = new System.Drawing.Size(75, 23); this.BtnValidate.TabIndex = 3; this.BtnValidate.Text = "Validate"; this.BtnValidate.UseVisualStyleBackColor = true; this.BtnValidate.Click += new System.EventHandler(this.BtnValidate_Click); // // StudentGrades // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(431, 181); this.Controls.Add(this.BtnValidate); this.Controls.Add(this.TxtScore); this.Controls.Add(this.LblMessage); this.Controls.Add(this.LblScore); this.Name = "StudentGrades"; this.Text = "Student Grade Application"; this.ResumeLayout(false); this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label LblScore; private System.Windows.Forms.Label LblMessage; private System.Windows.Forms.TextBox TxtScore; private System.Windows.Forms.Button BtnValidate; } }

Create a form that gets the input from a user from 0-100. You will need to make 3 methods for this application. Your first method must get the users input and validates that the entry is valid. Use logic to ensure the input is accurate, if the user enters an invalid entry throw a message box to the user with the error. The user must have a successful entry to proceed. We will expand on validation and exceptions in Lab 5. Once the score is validated send the score to a second method which assigns a letter grade. Use the following grading schema and use integer values for your scoring. = 60 and = 70 and = 80 and = 90 is an A. Once a grade is assigned pass the score and the letter grade to a Third Method. The third method will handle display and concatenate the results into a single string as displayed in the image below. Student Grade Application Score (0-100): 85 Validate You entered an 85 which is a Bleter Grade

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Knowledge Discovery In Databases

Authors: Gregory Piatetsky-Shapiro, William Frawley

1st Edition

0262660709, 978-0262660709

More Books

Students also viewed these Databases questions