Posts

Showing posts from October, 2023

If_Else_Example

  import "dart:io" ; class Student { var sname , sroll , sage ; void getData (String s , int r , int a) { sname = s ; sroll = r ; sage = a ; print( "Below are your subjects : \n Maths \n English \n Hindi \n " ) ; print( "How many marks you have got in Maths ? : " ) ; var mathsMark = stdin.readLineSync() ; if (int. parse (mathsMark!) <= 33 ) { print( "Sorry, You are Fail in Maths Subject" ) ; } else if (int. parse (mathsMark) > 33 && int. parse (mathsMark) < 50 ) { print( "Good, Your Maths mark is between 33 to 50" ) ; } else if (int. parse (mathsMark) > 50 && int. parse (mathsMark) < 70 ) { print( "Very Good, Your Maths mark is between 50 to 70" ) ; } else if (int. parse (mathsMark) > 70 ) { print( "Excellent, You have distinctive in Maths Subject, Congratulations!" ) ; print( "How many times have you atte...

If_Else_Dart

  import "dart:io" ; class User { var uname , password , mobileno , uname1 , password1 , mobileno1 ; void registration (String a , int b , int c) { uname = a ; password = b ; mobileno = c ; } void login (String x , int y , int z) { uname1 = x ; password1 = y ; mobileno1 = z ; if ( uname1 == uname && password1 == password && mobileno1 == mobileno ) { print( "Login Successfully completed, Congratulations!" ) ; print( "Please Enter your Ege : " ) ; var age = stdin.readLineSync() ; if (int. parse (age!) >= 18 ) { print( "Which Vehicle you had driving ?" ) ; print( "Two Wheeler" ) ; print( "Four Wheeler" ) ; var wheel = stdin.readLineSync() ; if (wheel == "Two Wheeler" ) { print( "Now you are perfectly Eligible for Voting because Four Wheel is dangerous for accident" ) ; prin...

Switch_case_Example

  import "dart:io" ; /// Example 1 class Bank { var sa ; void showDetail () { print( "Employee Name : Hitesh Kachhela" ) ; print( "Employee age : 40" ) ; print( "Employee phone : 8566321497" ) ; print( "Employee salary : 5000" ) ; print( "Employee Adhar No : 9644 3218 7455" ) ; } void taCalculation (int a) { sa = a ; var ta = ( sa * 2 )/ 100 ; var da = ( sa * 5 )/ 100 ; var hra = ( sa * 20 )/ 100 ; var pf = ( sa * 18 )/ 100 ; var total_salary = sa + sa ; print( "Your TA is : ${ta} " ) ; print( "Your DA is : ${da} " ) ; print( "Your HRA is : ${hra} " ) ; print( "Your PF is : ${pf} " ) ; print( "Your Total salary is : ${total_salary} " ) ; } } void main () { Bank object = new Bank () ; print( "Please Enter the value of Salary : " ) ; var salary = int. parse (stdin.readLineSync()!) ; prin...

Switch_case_Dart

  import "dart:io" ; class Task { var value1 , value2 ; void addition (int a , int b) { value1 = a ; value2 = b ; var sum = value1 + value2 ; print(sum) ; } void subtraction (int c , int d) { value1 = c ; value2 = d ; var sub = value1 - value2 ; print(sub) ; } void multiplication (int e , int f) { value1 = e ; value2 = f ; var mul = value1 * value2 ; print(mul) ; } void division (int a , int b) { value1 = a ; value2 = b ; var div = value1 / value2 ; print(div) ; } } void main () { Task object = new Task () ; print( "Please Enter the value of Number 1 : " ) ; var no1 = stdin.readLineSync() ; print( "Please Enter the value of Number 2 : " ) ; var no2 = stdin.readLineSync() ; print( "Please select choice from below options: " ) ; print( "1 : (Addition) \n 2 : (Subtraction) \n 3 : (Multiplication) \n 4 : (Division)" ) ; print( "Enter your ...

Patterns in Dart

  import 'dart:io' ; /// Parameters to find /// Number of Outer loop runs = Total number of Rows will count in desired pattern /// Number of Inner loop runs = Total number of Columns will count in desired pattern /// What to print = stdout.write(" "); void main () { /// Pattern 1 // for (int i = 1; i <= 5; i++) { //Outer loop // for (int j = 1; j <= 5; j++) { //Inner loop // stdout.write("* "); //In Output, number of rows are 5 so that Outer loop will be i=5(five) times loop // } //In Output, number of Columns are 5 so that Inner loop will be j=5(five) times loop // stdout.write("\n"); //Logic: Number of Rows = value of "i" in Outer loop // } //Logic: Number of Columns = value of "j" in Inner loop //Output should be: // * * * * * // * * * * * // * * * * * // * * * * * // * * * * * ///NOTE : If Row's number is repeated...

Exception_CustomException_Dart

  //Making Custom Exception by User(User defined Exception) // void main () { try { checkAge( 10 ) ; } catch (e) { print(e.toString()) ; } } void checkAge (int age) { if (age < 18 ) { throw MyException ( "This is Eligible for Voting!" ) ; } } class MyException implements Exception { var message = "" ; MyException(String msg) { this . message = msg ; } @override String toString () { return message ; } }

Exception_Dart

  import "dart:io" ; // void main() { // try { // checkage(10); // } catch(e) { // print(e); // } // } // void checkage(int age) { // if(age < 18) { // throw new FormatException("This is not Eligible"); // } // } //Example 1 // void main() { // int x = 12; // int y = 0; // int ans; // // try { // ans = x ~/ y; // } catch(e) { // print(e); // } // } //Example 2 // void main() { // var no1 = 10, no2 = 0, no3 = 0; // // no3 = no1 ~/ no2; //1st Method to indicate // no3 = (no1 / no2) as int; //2nd Method to indicate // print(no3); // } //Example 3 // void main() { // //Program 1: // // double no1 = 10; // // double no2 = 0; // // double no3 = 0; // // no3 = no1/no2; // // print(no3); //OUTPUT : Infinity // // // //Program 2 : // //Here below in this case program will stop // // int no4 = 10; // // int no5 = 0; // // int no6 = 0; // // no6 = no4 ~/ no5; // // print(no6); //OUTPUT : Unhandl...

Array

  import "dart:io" ; // void main() // { // var fruits = ["apple","mango","banana","pineapple","grapes","watermelon","pomegranate"]; // // print(fruits); //printing Whole Array // // fruits.add("orange"); //Add Element in Array // fruits.add("coconut");//Add Element in Array // fruits.insert(1,"coconut"); //Insert Element at particular Index position in Array // fruits.insert(3, "apple"); //Insert Element at particular Index position in Array // print(fruits); // // // print(fruits[0]); // // print(fruits[1]); // // print(fruits[2]); // // print(fruits[3]); // // print(fruits[4]); // // print(fruits[5]); // // // for(int i = 0; i < fruits.length; i++) // // { // // print(fruits[i]); // // } // // // var cars = ["maruti_suzuki","toyota","hyundai","bmw","mahindra"]; // // // ...

Set_(Collection)_Dart

  void main () { //There are two ways to declare Set as shown below : //1) Set<Int> ratings = {}; (Here, "ratings" is name of Set) //2) var ratings = <Int>{}; /*Set<int> ratings = {}; var ratings1 = <int>{};*/ ///NOTE : Set will always remove(will not print duplicate elements) duplicate /// elements from the Set elements var theSet = { 10 , 20 , 30 , 40 , 50 , 60 , 20 , 70 , 50 , 10 , 80 , 30 , 90 , 100 } ; print(theSet) ; print( " \n " ) ; ///Getting the Number of Elements // print("Length is : ${theSet.length}"); ///Accessing an element by index // print(theSet.elementAt(0)); // print(theSet.elementAt(1)); // print(theSet.elementAt(2)); // print(theSet.elementAt(3)); // print(theSet.elementAt(4)); ///Also,you can use the first and last property to access the first and last elements respectively // print(theSet.first); // print(theSet.last); ///Adding an element to a set // theSet.add(6...

Map_Example_Dart

  import "dart:io" ; void main () { var cars = { "maruti" : 1 , "hyundai" : 2 , "toyota" : 3 , "tata" : 4 , "bmw" : 5 , "mercedes" : 6 , "skoda" : 7 , "renault" : 8 , "audi" : 9 , "kia" : 10 , "nissan" : 11 , "ford" : 12 , "mahindra" : 13 , "jaguar" : 14 , "honda" : 15 , "chevrolet" : 16 , "lamborghini" : 17 , "bentley" : 18 , "jeep" : 19 , "volvo" : 20 , } ; print( " $cars \n " ) ; print( "Enter the key : " ) ; var user = stdin.readLineSync() ; if (cars. keys .contains(user)) { print( " \n Above given key is Already Exist at Value ${cars[user]} in below Map \n " ) ; print(cars) ; } else { cars[ " $user " ] = 21 ; print(cars)...