ms_learn_csharp/005_Calc_and_print_grades/005_csharp.md

4.2 KiB
Raw Blame History

Guided Project

Calculate and print student grades

Introduction

Developers perform some tasks nearly every day. Tasks including declaring string and numeric variables, assigning and extracting values, and performing calculations are routine, but essential. Equally important is the task of communicating results to the application user. Mastering the ability to apply these skills to solve a given problem is something that every developer must learn to do.

Suppose you are a teacher's assistant at a school. You're tasked with developing an application that automates student grading. The application uses all of the scored assignments for each student to calculate their current overall grade/score for the class. The teacher has also provided a required format for reporting the student grades.

This module will guide you through the steps required to develop your Student Grading application. Your code will declare and assign values to variables based on student names, perform various numeric calculations, and display the results. Calculations include determining the sum of assignment scores and calculating the current grade for each student. To display the results in the required format, you'll use Console.WriteLine(), as well character escape sequences that will help format your results.

By the end of this module, you'll be able to write code that uses various variable types, performs numeric calculations, and displays formatted data for the user.

Note
This is a guided project module where you'll complete an end-to-end project by following step-by-step instructions.

Learning objectives

In this module, you'll practice how to:

  • Work with variables to store and retrieve data
  • Perform basic math operations
  • Format strings to present results

Prerequisites

  • Beginner level experience with a .NET editor
  • Beginner level experience with basic C# syntax rules
  • Beginner level experience with performing math operations on variables
  • Beginner level experience with creating literal values and declare variables of basic data types like string, int, and decimal
  • Beginner level experience with string concatenation and string interpolation

Prepare for guided project

You'll be using the .NET Editor as your code development environment. You'll be writing code that uses string and numeric variables, performs calculations, and displays results to a console.

Project overview

You're developing a Student Grading application that automates the calculation of current grades for each student in a class. The parameters for your application are:

  • You're given a short list of four students and their five assignment grades.
  • Each assignment grade is expressed as an integer value, 0-100, where 100 represents 100% correct.
  • Final scores are calculated as an average of the five assignment scores.
  • Your application needs to perform basic math operations to calculate the final grades for each student.
  • Your application needs to output/display each students name and final score.

Currently, the teachers grade book shows the graded assignments for each student as follows:

Name G1 G2 G3 G4 G5
Sophia 93 87 98 95 100
Nicolas 80 83 82 88 85
Zahirah 84 96 73 85 79
Jeong 90 92 98 100 97

The teacher requires that the calculated grades for each student are displayed as follows:

Student     Grade
Sophia      94.6  A
Nicolas     83.6  B
Zahirah     83.4  B
Jeong       95.4  A

Setup

Use the following steps to prepare for the Guided project exercises:

Open the .NET Editor coding environment.

Copy and paste the following code into the .NET Editor. These values represent the graded assignments for each student.

// initialize variables - graded assignments 
int currentAssignments = 5;

int sophia1 = 93;
int sophia2 = 87;
int sophia3 = 98;
int sophia4 = 95;
int sophia5 = 100;

int nicolas1 = 80;
int nicolas2 = 83;
int nicolas3 = 82;
int nicolas4 = 88;
int nicolas5 = 85;

int zahirah1 = 84;
int zahirah2 = 96;
int zahirah3 = 73;
int zahirah4 = 85;
int zahirah5 = 79;

int jeong1 = 90;
int jeong2 = 92;
int jeong3 = 98;
int jeong4 = 100;
int jeong5 = 97;

Now you're ready to begin the Guided project exercises. Good luck!