Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solutions For First 3 Assignments #57

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions session_1/Solution/Program1.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import 'dart:io';

void printFibonacci(int n) {
List fibonacci = [0, 1];
for (int i = 2; i < n; i++) {
fibonacci.add(fibonacci[i - 1] + fibonacci[i - 2]);
}

stdout.write("\n");

print("First $n Fibonacci Numbers are : ");

for (var i=0;i<n;i++) {
stdout.write(fibonacci[i]);
stdout.write(' ');
}
}

void main() {
print(
"******** Program to print the first N Fibonacci numbers(N is specified by the user) ********");

stdout.write("Enter the value of N : ");
try {
int n = int.parse(stdin.readLineSync()!);
if (n <= 0) {
print("N must be greater than 0!!!");
return;
} else {
printFibonacci(n);
}
} catch (e) {
print("Please Enter Only Number!!!");
}
}
45 changes: 45 additions & 0 deletions session_1/Solution/Program2.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'dart:io';

void isSemiPrime(int n) {
int original_number = n;
int count = 0;
for (int i = 2; i * i <= n; i++) {
while (n % i == 0) {
n = n ~/ i;
count++;
if (count >= 2) {
break;
}
}
}

if (n > 1) {
count++;
}

stdout.write("\n");

if (count == 2) {
print("$original_number is a semiprime number!!");
} else {
print("$original_number is not a semiprime number!!");
}
}

void main() {
print(
"******** Program to check whether the given number is semiprime or not ********");

stdout.write("Enter the value of N : ");
try {
int n = int.parse(stdin.readLineSync()!);
if (n <= 0) {
print("N must be greater than 0!!!");
return;
} else {
isSemiPrime(n);
}
} catch (e) {
print("Please Enter Only Number!!!");
}
}
68 changes: 68 additions & 0 deletions session_1/Solution/Program3.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import 'dart:io';

bool isPrime(int n) {
int count = 0;
for (int i = 1; i <= n; i++) {
if (n % i == 0) {
count++;
}
}

return count == 2;
}

void CheckSumPrime(int length, List<int> array) {
int sum = 0;
var prime_numbers = [];
for (int i = 0; i < length; i++) {
if (isPrime(array[i])) {
prime_numbers.add(array[i]);
sum += array[i];
}
}

if (isPrime(sum)) {
stdout.write('\n');
print("Prime elements in the array are : ");
for (var i in prime_numbers) {
stdout.write(i);
stdout.write(' ');
}

stdout.write('\n\n');

print("Sum of these prime elements is : $sum");
stdout.write('\n');

print("Therefore,Sum of prime elements of the array is prime.");
} else {
print("Sum of prime elements of the array is Not prime.");
}
}

void main() {
print(
"******** Program to check whether the sum of prime elements of the array is prime or not ********");

try {
int length;
List<int> array = [];

stdout.write("Enter the length of the array : ");

length = int.parse(stdin.readLineSync()!);

if (length > 0) {
print("Enter the elements of the array : ");
for (int i = 0; i < length; i++) {
array.add(int.parse(stdin.readLineSync()!));
}

CheckSumPrime(length, array);
} else {
print("Length of the array must be greater than 0!!!");
}
} catch (e) {
print("Please Enter Only Number!!!");
}
}
Binary file added session_1/Solution/Program_1_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added session_1/Solution/Program_2_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added session_1/Solution/Program_3_1_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added session_1/Solution/Program_3_2_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added session_1/Solution/Program_4_1_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added session_1/Solution/Program_4_2_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added session_1/Solution/Program_4_3_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added session_1/Solution/Program_4_4_output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
208 changes: 208 additions & 0 deletions session_1/Solution/courses.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
import 'dart:io';

class BranchElective {
String courseName = '', courseCode = '';
String Branch = '';
int Year = 0;
Map BranchElectiveCourses = Map();

void set SetCourseName(String Cname) {
this.courseName = Cname;
}

void set SetCourseCode(String Ccode) {
this.courseCode = Ccode;
}

void AddToList() {
if (this.BranchElectiveCourses["$Year $Branch"] == null) {
this.BranchElectiveCourses["$Year $Branch"] = [
[this.courseName, this.courseCode]
];
} else {
this
.BranchElectiveCourses["$Year $Branch"]
.add([this.courseName, this.courseCode]);
}
}

void GetBranchElectives(String branch, int year) {
if (this.BranchElectiveCourses.isEmpty) {
stdout.write("\n");

print(
"There are no Branch Electives for Branch : $branch and Year : $year!!!");
stdout.write("\n");
return;
} else {
if (BranchElectiveCourses["$year $branch"] == null) {
stdout.write("\n");
print(
"There are no Branch Electives for Branch : $branch and Year : $year!!!");
stdout.write("\n");
return;
}

List BranchElectivesList = this.BranchElectiveCourses["$year $branch"];

if (BranchElectivesList.isEmpty) {
stdout.write("\n");
print(
"There are no Branch Electives for Branch : $branch and Year : $year!!!");
stdout.write("\n");
return;
} else {
stdout.write("\n");

print(
"List Of Branch Electives for Branch : $branch and Year : $year are : ");
stdout.write("\n");

print("Sr.No\tCourse Name\tCourse Code");

for (int i = 0; i < BranchElectivesList.length; i++) {
print(
"${i + 1}\t${BranchElectivesList[i][0]}\t\t${BranchElectivesList[i][1]}");
}
}
}
}

void AddValues() {
String branch;
int year;

print("Enter branch : ");
branch = stdin.readLineSync()!;

print("Enter year : ");
year = int.parse(stdin.readLineSync()!);

this.Branch = branch;
this.Year = year;

String CName, CCode;

print("Enter course name : ");
CName = stdin.readLineSync()!;

print("Enter course code : ");
CCode = stdin.readLineSync()!;

this.SetCourseName = CName;
this.SetCourseCode = CCode;

this.AddToList();

print(
"\nCourse Name : $CName with Course Code : $CCode for Branch : $branch and Year : $year has been added to the Branch Electives!!\n");
}
}

class OpenElective {
String courseName = '', courseCode = '';
List<List> OpenElectiveCourses = [];

void set SetCourseName(String Cname) {
this.courseName = Cname;
}

void set SetCourseCode(String Ccode) {
this.courseCode = Ccode;
}

void AddToList() {
this.OpenElectiveCourses.add([this.courseName, this.courseCode]);
}

void GetOpenElectives() {
if (this.OpenElectiveCourses.isEmpty) {
stdout.write("\n");
print("There are no Open Electives!!!");
return;
} else {
stdout.write("\n");
print("List Of Open Electives : ");
stdout.write("\n");
print("Sr.No\tCourse Name\tCourse Code");
for (int i = 0; i < this.OpenElectiveCourses.length; i++) {
print(
"${i + 1}\t${OpenElectiveCourses[i][0]}\t\t${OpenElectiveCourses[i][1]}");
}
}
}

void AddValues() {
String CName, CCode;

print("Enter course name : ");
CName = stdin.readLineSync()!;

print("Enter course code : ");
CCode = stdin.readLineSync()!;

this.SetCourseName = CName;
this.SetCourseCode = CCode;
this.AddToList();

print(
"\nCourse Name : $CName with Course Code : $CCode has been added to the Open Electives!!\n");
}
}

void main() {
try {
bool flag = false;
BranchElective branchElective = BranchElective();
OpenElective openelective = OpenElective();
do {
print("Enter type of user 1.Admin 2.Student");
int UserType = int.parse(stdin.readLineSync()!);

if (UserType == 1) {
print("Enter course type 1.Open elective 2.Branch elective");
int CourseType = int.parse(stdin.readLineSync()!);
if (CourseType == 1) {
openelective.AddValues();
} else if (CourseType == 2) {
branchElective.AddValues();
} else {
print("Invalid Input!!!");
print("Please Select number 1 or 2.");
}
} else if (UserType == 2) {
String branch;
int year;

print("Enter branch : ");
branch = stdin.readLineSync()!;

print("Enter year : ");
year = int.parse(stdin.readLineSync()!);

openelective.GetOpenElectives();
branchElective.GetBranchElectives(branch, year);
} else {
print("Invalid Input!!!");
print("Please Select number 1 or 2.");
}

stdout.write('Do you want to Add or View Courses Again?(Y/N) : ');

String input = stdin.readLineSync()!;
if (input == 'Y' ||
input == 'y' ||
input == 'Yes' ||
input == "yes" ||
input == 'YES') {
flag = true;
} else {
flag = false;
}
} while (flag);
print("Thank you!!");
} catch (e) {
print("Exception Occured!!!!");
print("Exception : $e");
}
}
33 changes: 33 additions & 0 deletions session_3/Solution/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# trivia_app

NUMBER TRIVIA APP

## Getting Started 🤩😍


* [Installation Guide for Flutter](https://flutter.dev/docs/get-started/install).
* After setting up flutter download the code and then unzip.
* Open code in Visual Studio Code Editor.([Installation Guide for Visual Studio Code](https://code.visualstudio.com/docs))
* [Setup flutter in VS Code](https://docs.flutter.dev/development/tools/vs-code).
* Optional : Connect Laptop and your Mobile through USB cable then enable USB debugging option in your mobile.([Steps to enable USB debugging option in android](https://www.youtube.com/results?search_query=enable+debugging+mode+android))
* Goto trivia_app/lib under this execute the file main.dart without debugging i.e Click on Run Without Debugging option in vs code.

## App Features ✨

* Added App Icon.
* Added Splash Screen.
* Used Different Fonts.
* Added Images.
* Validation Is Done For User Input.
* Added Multiple Floating Buttons (Copy,Refresh and Exit) To Bottom Right Corner.
* Added Confirmation AlertDialog.
* Added Copy To Clipboard Option.

## App Demo Video 🎥🎥

* [NUMBER TRIVIA APP DEMO VIDEO](trivia_app/images/Demo_Video.mp4)

## App GIF

<p> <img src="trivia_app/images/Demo.gif" width="200">

Loading