Skip to content
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
30 changes: 30 additions & 0 deletions assignments/assignment1_dart_codes/1_fibonacci.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'dart:io';

//function to print the fibonacci series
void fibonacci_series(int n) {
//initialize initial variables a,b
int a = 0;
int b = 1;
//print the values of a ,b
print(a);
print(b);
int c;
//loop for n-2 times
for (int i = 0; i < n - 2; i++) {
//add a and b and store the value in c and print its value
c = a + b;
print(c);
//update the values of a and b
a = b;
b = c;
}
}

void main() {
print("Enter no. of terms to be printed: ");
//input n
int n = int.parse(stdin.readLineSync()!);
print("The $n fibonacci terms are: ");
//call the function
fibonacci_series(n);
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions assignments/assignment1_dart_codes/2_semiprime.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'dart:io';

//function to chekc if a number is semiprime or not
bool semiprime(int num) {
//a number is semiprime if it is product of two prime numbers
//count will be storing the count of numbers whose product = num
int count = 0;

for (int i = 2; count < 2 && i * i <= num; ++i) {
while (num % i == 0) {
num = num ~/ i;
++count; // Increment count of prime numbers
}
}

// If number is greater than 1, add it to the count variable
// as it indicates the number remain is prime number
if (num > 1) ++count;

// Return '1' if count is equal to '2' else
// return '0'
return (count == 2);
}

void main() {
print("Enter a number: ");
//input n
int n = int.parse(stdin.readLineSync()!);
if (semiprime(n))
print("$n is a semiprime ");
else
print("$n is not a semiprime ");
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions assignments/assignment1_dart_codes/3_prime_sum.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'dart:io';

//Function to check prime numbers
bool checkPrime(int num) {
bool res = true;
//repeat a loop from t to sqrt(num)
for (int i = 2; i * i < num; i++) {
//if i divides num,then the number is not prime,so break from the loop
if (num % i == 0) {
res = false;
break;
}
}
//return bool value of res
return res;
}

//Checking prime numbers in an array and summing them
bool prime_nums(List<int> arr) {
int sum = 0;
//repeat a loop for all elements of arr
for (int i = 0; i < arr.length; i++) {
//if that number is prime and that num is not 1 then add that element to the sum
if (checkPrime(arr[i]) && arr[i] != 1) sum += arr[i];
}
//check if the sum is now a prime number or not and return the value
return checkPrime(sum);
}

void main() {
print("Enter number of elements");
//input size of array
int n = int.parse(stdin.readLineSync()!);
print("Enter an array: ");
//array declaration
var arr = <int>[];
//input array elements
for (int i = 0; i < n; i++) {
arr.add(int.parse(stdin.readLineSync()!));
}
//call the function prime_nums
if (prime_nums(arr))
print("Sum of prime elements is prime\n");
else
print("Sum of prime elements is non-prime\n");
}
Binary file added assignments/assignment1_dart_codes/3_primesum.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
90 changes: 90 additions & 0 deletions assignments/assignment1_dart_codes/4_courseElective.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import 'dart:io';

//class definitions
class Open_Elective {
//string variables for coursename and coursecode
var courseName = <String>[];
var courseCode = <String>[];
//functions
void addCourse() {
//input course name and code and add them to repective lists
print("Enter course name and code");
//input in a single line both name and code
String? temp = stdin.readLineSync();
//split the temp input by " " and assign it to a list
var tempList = temp!.split(" ");
//0th index of list represent course name and 1st index is the course code
courseName.add(tempList[0]);
courseCode.add(tempList[1]);
}

//function to print all the course name and code
void viewCourse() {
for (int i = 0; i < courseCode.length; i++)
print("Course Name: ${courseName[i]} Course Code: ${courseCode[i]}");
}
}

//branch elective class definition inherited from open elective class
class Branch_Elective extends Open_Elective {
//variables of this class
var branch, year;
//functions
void addElective() {
//input branch name and year
print("Enter branch and year");
String? temp = stdin.readLineSync();
var tempList = temp!.split(" ");
branch = tempList[0];
year = tempList[1];
//call the function to add elective coure for that brach and year
addCourse();
}

//function to print the course name and code of that specific student whose branch and elective are given
void viewElective(String br, String yr) {
//repeat a loop
for (int i = 0; i < courseCode.length; i++) {
//if given branch and year matches with the one in the list then print its name and code
if (branch == br && year == yr)
print("Course Name: ${courseName[i]} Course Code: ${courseCode[i]}");
}
}
}

void main() {
//create class objects
var openElectiveObject = new Open_Elective();
var branchElectiveObject = new Branch_Elective();
while (true) {
print("\nEnter type of user 1.Admin 2.Student 3. Exit");
//input user's choice
int user_choice = int.parse(stdin.readLineSync()!);
if (user_choice == 1) {
print("Enter course type 1.Open elective 2.Branch elective");
//input user's choice on elective
int elective_choice = int.parse(stdin.readLineSync()!);
//if choice is 1, call addCourse() function
if (elective_choice == 1)
openElectiveObject.addCourse();
//else call function to addElective()
else if (elective_choice == 2) branchElectiveObject.addElective();
} else if (user_choice == 2) {
print("Enter branch and year");
//input user's branhc and year
String? temp = stdin.readLineSync();
var templist = temp!.split(" ");
String branch = templist[0];
String year = templist[1];
//print all open electives
print("\nOpen Electives are: ");
openElectiveObject.viewCourse();
//print all branch electives according to student's branch and year
print("\nBranch Electives are: ");
branchElectiveObject.viewElective(branch, year);
} else {
print("Thank you");
break;
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions assignments/assignment2_number_trivia/number_trivia/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

# Flutter/Dart/Pub related
**/doc/api/
**/ios/Flutter/.last_build_id
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
/build/

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
10 changes: 10 additions & 0 deletions assignments/assignment2_number_trivia/number_trivia/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: 77d935af4db863f6abd0b9c31c7e6df2a13de57b
channel: stable

project_type: app
37 changes: 37 additions & 0 deletions assignments/assignment2_number_trivia/number_trivia/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# NUMBER TRIVIA

A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.

## About the project

The NUMBER TRIVIA is an app in which user enters a number and some interesting facts about that number is displayed.
The facts regarding that number can be about some Math, Trivia or some important year.

## Features Added

1. Added backgroud image
2. App Icon added
3. More than two Text fonts and styles used
4. Splash screen added

## App recording





https://user-images.githubusercontent.com/69628293/150630905-18fa2b88-f2b3-49b4-9bb9-1862e9d73fb8.mp4

Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
gradle-wrapper.jar
/.gradle
/captures/
/gradlew
/gradlew.bat
/local.properties
GeneratedPluginRegistrant.java

# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
**/*.keystore
**/*.jks
Loading