Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
141 views9 pages

Dart Assignment 1

The document describes a Dart program that allows a user to input a temperature value and converts it between Celsius and Fahrenheit. The program displays a menu for the user to select the conversion type, gets the temperature value from the user, performs the conversion, and displays the result.

Uploaded by

Vandana Garia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
141 views9 pages

Dart Assignment 1

The document describes a Dart program that allows a user to input a temperature value and converts it between Celsius and Fahrenheit. The program displays a menu for the user to select the conversion type, gets the temperature value from the user, performs the conversion, and displays the result.

Uploaded by

Vandana Garia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Dart Assignment

Ans 1 .
import 'dart:io';

void main() {

print("Temperature Conversion Program");

// Choose the conversion direction

print("1. Celsius to Fahrenheit");

print("2. Fahrenheit to Celsius");

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

if (choice == 1) {

// Celsius to Fahrenheit conversion

print("Enter temperature in Celsius:");

double celsius = double.parse(stdin.readLineSync()!);

double fahrenheit = (celsius * 9 / 5) + 32;

print("$celsius°C is $fahrenheit°F");

} else if (choice == 2) {

// Fahrenheit to Celsius conversion

print("Enter temperature in Fahrenheit:");

double fahrenheit = double.parse(stdin.readLineSync()!);

double celsius = (fahrenheit - 32) * 5 / 9;

print("$fahrenheit°F is $celsius°C");
} else {

print("Invalid choice.");

Output -:
Ans 2

import 'dart:io';

void main() {

print('Enter First Number:');

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

print('Enter Second Number:');

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

if (N == 50 || M == 50 || (M + N) == 50) {

print('Yes');

} else {

print('NO');

Output -:
Ans 3

import 'dart:io';

void main() {

print('Enter the Number:');

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

int result = 0;

for (int i = N; i > 0; i = (i / 10).floor()) {

result += (i % 10);

print('Sum of the digits is $result !');

Output -:
Ans 4 -:

import 'dart:io';

bool dividebytwo(int N) {

if (N % 2 == 0) {

print('Number is Divisible by 2');

return true;

return false;

bool dividebythree(int N) {

int result = 0;

int num = N;

while (num > 0) {

result += (num % 10);

num ~/= 10;

if (result % 3 == 0) {

print('Number is divisible by 3');

return true;

}
return false;

bool dividebyfour(int N) {

int M = N % 100;

if (M % 4 == 0) {

print('Number is divisible by 4');

return true;

return false;

bool dividebyfive(int N) {

if (N % 5 == 0) {

print('Number is divisible by 5');

return true;

return false;

bool dividebysix(int N) {

int result = 0;

int num = N;

while (num > 0) {

result += (num % 10);


num ~/= 10;

if (result % 3 == 0 && N % 2 == 0) {

print('Number is divisible by 6');

return true;

return false;

bool dividebyseven(int N) {

int M = N ~/ 10 - (N % 10) * 2;

if (M % 7 == 0) {

print('Number is divisible by 7');

return true;

return false;

bool dividebyeight(int N) {

int M = N % 1000;

if (M % 8 == 0) {

print('Number is divisible by 8');

return true;

return false;
}

bool dividebynine(int N) {

int result = 0;

int num = N;

while (num > 0) {

result += (num % 10);

num ~/= 10;

if (result % 9 == 0) {

print('Number is divisible by 9');

return true;

return false;

bool dividebyten(int N) {

if (N % 10 == 0) {

print('Number is divisible by 10');

return true;

return false;

void main() {

print('Enter the Number:');


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

dividebytwo(N);

dividebythree(N);

dividebyfour(N);

dividebyfive(N);

dividebysix(N);

dividebyseven(N);

dividebyeight(N);

dividebynine(N);

dividebyten(N);

Output -:

You might also like