From f32f956d2512d84df3648293cfff133e4746e7a6 Mon Sep 17 00:00:00 2001 From: David Nanjila Date: Mon, 25 Mar 2024 08:32:11 +0300 Subject: [PATCH 1/6] Chore: Create a Dart program that prints personal information --- program1..dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/program1..dart b/program1..dart index d762a43..2a032e9 100644 --- a/program1..dart +++ b/program1..dart @@ -1,2 +1,8 @@ -## Program 1: Display Personal Information -Write a Dart program using variables to display your name, age, school, and a hobby. Print it in one logical sentence. +// Program 1: Display Personal Information +void main(){ + String name = "David"; + int age = 22; + String school = 'Zetech University'; + String hobby = 'Listening to music on Spotify'; + print("My name is $name, I am $age years old, I live in $school and I like $hobby."); +} \ No newline at end of file From 98d62b9695649c00797b8acb12ff067f22705b96 Mon Sep 17 00:00:00 2001 From: David Nanjila Date: Mon, 25 Mar 2024 09:04:13 +0300 Subject: [PATCH 2/6] Chore: Create a dart function that performs mathematical operation using a class and functions --- functions.dart | 56 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/functions.dart b/functions.dart index 914640c..faad4a0 100644 --- a/functions.dart +++ b/functions.dart @@ -1,2 +1,54 @@ -## Program 2: Perform Mathematical Operations with Functions -Write a Dart program that performs two mathematical operations using functions. +// Program 2: Perform Mathematical Operations with Functions +//Write a Dart program that performs two mathematical operations using functions. +import 'dart:io'; + +class MathematicsProgram{ + int number1; + int number2; + + MathematicsProgram(this.number1, this.number2); + int add(){ + int result = number1 + number2; + return result; + } + int subtract(){ + return number1 - number2; + } + int multiply(){ + return number1 * number2; + } + num divide(){ + return number1 / number2; + } +} +void main(){ + //ask the user to enter two numbers + print("Enter the first number: "); + + int num1 = int.parse(stdin.readLineSync()!); + print("Enter the second number: "); + int num2 = int.parse(stdin.readLineSync()!); + + MathematicsProgram mp = MathematicsProgram(num1, num2); + print("Choose your operation: \n1. Add\n2. Subtract\n3. Multiply\n4. Divide\n"); + + int choice = int.parse(stdin.readLineSync()!); + switch(choice){ + case 1: + print(mp.add()); + break; + case 2: + print(mp.subtract()); + break; + case 3: + print(mp.multiply()); + break; + case 4: + print(mp.divide()); + break; + default: + print("Invalid choice"); + break; + } + +} \ No newline at end of file From 92a9bc7833dfa2cbfaf40d4417952bd2232afc9b Mon Sep 17 00:00:00 2001 From: David Nanjila Date: Mon, 25 Mar 2024 09:23:56 +0300 Subject: [PATCH 3/6] Create a source code to calculate grade for the students, used class object and control flow --- controlflow.dart | 52 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/controlflow.dart b/controlflow.dart index d6dc466..c61f409 100644 --- a/controlflow.dart +++ b/controlflow.dart @@ -1,7 +1,47 @@ +// Program 3: Determine Grade Based on Marks +// Write a Dart program to determine the grade based on a student's marks. The program should print out the appropriate grade according to the following criteria: +// - If the marks are greater than 85, print "Excellent". +// - If the marks are between 75 and 85 (inclusive), print "Very Good". +// - If the marks are between 65 and 75 (inclusive), print "Good". +// - If the marks are below 65, print "Average". +import 'dart:io'; +class studentGradingSystem{ -## Program 3: Determine Grade Based on Marks -Write a Dart program to determine the grade based on a student's marks. The program should print out the appropriate grade according to the following criteria: -- If the marks are greater than 85, print "Excellent". -- If the marks are between 75 and 85 (inclusive), print "Very Good". -- If the marks are between 65 and 75 (inclusive), print "Good". -- If the marks are below 65, print "Average". + int english; + int maths ; + int science; + studentGradingSystem(this.english, this.maths, this.science); + String grade(){ + int marks = (this.english + this.maths + this.science); + num Average = marks / 3; + + if(Average >= 85){ + return "Excellent"; + } + else if(Average >= 75 && maths >= 85){ + return "Very Good"; + } + else if(Average >= 65 && maths >= 75){ + return "Good"; + } + else if(Average < 65 && maths >= 65){ + return "Average"; + } + else{ + return "Fail"; + } + } +} +void main(){ + print("********Welcome to the student grading system************"); + print("Please enter your English language marks: "); + int english = int.parse(stdin.readLineSync()!); + print("Please enter your Maths marks: "); + int maths = int.parse(stdin.readLineSync()!); + print("Please enter your Science marks: "); + int science = int.parse(stdin.readLineSync()!); + studentGradingSystem student = studentGradingSystem(english, maths, science); +String grade1 = student.grade(); + print("Your grade is: $grade1"); + +} \ No newline at end of file From 3ca93e324bf3e654462380fd8f7afc8a5f83a230 Mon Sep 17 00:00:00 2001 From: David Nanjila Date: Mon, 25 Mar 2024 09:28:38 +0300 Subject: [PATCH 4/6] update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2f9d18e..d0e42dc 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # DART-HACKATHON-REPOSITORY + # Dart Programs From c344630d0a1674d5a8db765a3b2a2b2376b57439 Mon Sep 17 00:00:00 2001 From: David Nanjila Date: Mon, 25 Mar 2024 10:03:21 +0300 Subject: [PATCH 5/6] Chore Update readme --- README.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index d0e42dc..2a426ac 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,16 @@ ## Program 1: Display Personal Information -Write a Dart program using variables to display your name, age, school, and a hobby. Print it in one logical sentence. +Wrote a Dart program using variables to display my name, age, school, and a hobby. Print it in one logical sentence. ## Program 2: Perform Mathematical Operations with Functions -Write a Dart program that performs two mathematical operations using functions. +- Was to write Dart program that performs two mathematical operations using functions. + - added some more math operations to enhance user experience ## Program 3: Determine Grade Based on Marks -Write a Dart program to determine the grade based on a student's marks. The program should print out the appropriate grade according to the following criteria: -- If the marks are greater than 85, print "Excellent". -- If the marks are between 75 and 85 (inclusive), print "Very Good". -- If the marks are between 65 and 75 (inclusive), print "Good". -- If the marks are below 65, print "Average". +Wrote a Dart program to determine the grade based on a student's marks. The program should print out the appropriate grade according to the following criteria: +## I added the feature that the program should calcute the grade base on the average marks +- If the average marks greater than 85, print "Excellent". +- If the average marks between 75 and 85 (inclusive), print "Very Good". +- If the average marks between 65 and 75 (inclusive), print "Good". +- If the average marks are below 65, print "Average". From cff2e767a040a6ba1c9b0f8c10b16bd22a2eea15 Mon Sep 17 00:00:00 2001 From: David Nanjila <117593948+stoicdavi@users.noreply.github.com> Date: Wed, 27 Mar 2024 11:36:47 +0300 Subject: [PATCH 6/6] Chore: Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 2a426ac..c3791e5 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,10 @@ Wrote a Dart program to determine the grade based on a student's marks. The prog - If the average marks between 75 and 85 (inclusive), print "Very Good". - If the average marks between 65 and 75 (inclusive), print "Good". - If the average marks are below 65, print "Average". + +## Feature +- The program ask for user to input marks for 3 subjects +- the average is auto calculated and the student is graded by the system + +### technology used +- Dart