Trending ▼   ResFinder  

ICSE Class X Mid-term 2025 : Chemistry

48 pages, 33 questions, 0 questions with responses, 0 total responses,    0    0
Lipika Singh
  
+Fave Message
 Home > rrrrrr28562546552 >

Formatting page ...

COMPUTER APPLICATIONS *LABORATORY ASSIGNMENTS COMPLETED DURING THE ACADEMIC SESSION 2024 - 2025 COMPILED BY CERTIFICATE: This is to certify that this is the bona fide work of NAME of class 9, section A, of St. Michaels School, Siliguri He has worked on the following assignments during the academic session of 2024-2025 The student s initiative, cooperativeness, and participation during the practical classes were: EXCELLENT/GOOD/AVERAGE/BELOW AVERAGE His aesthetic presentation, visual appeal, neatness, and expression in the assignment are: EXCELLENT/GOOD/AVERAGE/BELOW AVERAGE His content accuracy, creativity, and analysis of different programming concepts are: EXCELLENT/GOOD/AVERAGE/BELOW AVERAGE Student s Signature Evaluator s Signature Evaluator s signature TABLE OF CONTENTS 1. Write a program in Java to enter any number from 1 to 9,999. Print whether the number is a single digit, two-digit, three-digit or four-digit number. 2. The charges for sending a parcel from Siliguri to Patna are as follows: Weight of the Parcel Charge(Rs.) upto 2 kgs Rs. 100 3-6 kgs Rs. 200 7-10 kgs Rs. 300 Above 10 kgs Rs. 400 Write a program to enter the weight of the parcel and print the total amount to be paid. 3. The standard form of a quadratic equation is given by ax2 + bx + c = 0 where a, b and c are the coefficients of x2 , x and the constant respectively. D= b2 4ac, where d is known as the discriminant. If d>=0, the roots are possible and If d<0, the roots are imaginary. The roots of the equation are determined by the formula x = -b b2 -4ac 2a Write a program in Java to determine the roots of the equation after taking a, b and c as input. 4. A library charges fines for books returned late as per the following criteria: No. of Days Late Fine(Rs Per Day) Upto 7 days Rs 1.50 Next 7 days Rs 2.50 Next 10 days Rs 3.50 Above 24 days Rs 5.50 Write a program in Java to enter the number of days the book is returned late and print the total fine to be paid by the borrower. 5. Write a program to enter any number from 1 to 12 and print the corresponding month of the year. Also print the number of days present in that particular month. (Use switchcase). 6. Write a menu driven program to print whether a number entered is Prime or Perfect as per the user s choice. 7. Write a program to input any 15 numbers (including positive and negative) and print the following: i. ii. iii. iv. v. vi. Number of positive integers Number of negative integers Sum of positive numbers Sum of negative number Average of the positive numbers Average of the negative numbers 8. A prime number is said to be Twisted Prime , if the new number obtained after reversing the digits is also a prime number. Write a program to accept a number and check whether the number is Twisted Prime or not. Sample Input:167 Sample Output:761 167 is a Twisted Prime . 9. Write a program to print all Pronic numbers from 1 to 1000. 10. Write a menu driven program to enter any number and print whether the number is a CYCLO number or TWIST number as per the user s choice. A CYCLO NUMBER is one in which the first and the last digit is the same. A TWIST NUMBER is one in which the first digit is odd and the last digit is even. Example : 7254 11. The International Standard Book Number (ISBN) is a unique numeric book identifier which is printed on every book. The ISBN is based upon a 10 digit code. The ISBN is legal if: 1 * digit1 + 2 * digit2 + 3 * digit3 + 4 * digit4 + 5 * digit5 + 6 * digit6 + 7 * digit7 + 8* digit8 + 9 * digit9 + 10 * digit10 is divisible by 11. Write a program in Java to : Input the ISBN code as a 10-digit number If the ISBN is not a 10-digit number, then output the message Illegal ISBN and terminate the program If the number is a 10-digit number then complete the sum as explained above and print whether the number is a Legal ISBN or Illegal ISBN . For example : 1401601499 is a legal ISBN. 12. Write a program in Java to check whether a given number is an AUTOMORPHIC number or not. An Automorphic number is one which is present in the last digits of its square. 252 = 625, which is an AUTOMORPHIC number. 52 = 25, which is an AUTOMORPHIC number. 13. Write a menu driven program to print the sum of the following series as per the user s choice. i. ii. S = 0+3+8+15+ ..99 S = 2-4+6-8 .+18-20 14. Write a menu driven program to print the sum of the following series as per the user s choice. i. ii. 1 2 3 9 S = 2 + 3 + 4 + 10 S = 2 + 15. Write a menu driven program to print the following patterns as per the user s choice. 1 1 1 2 3 3 1 2 3 1 2 3 4 1 2 3 4 5 5 5 5 7 7 7 7 9 9 9 9 9 16. A TECH NUMBER has even number of digits. If the number is split in two equal halves, then the square of the sum of these halves is equal to the number itself. Write a program to print and generate all four digit tech numbers. Example : 3025 Square of the sum of the sum of the halves of 3025 = (30+25)2 = (55)2 = 3025 is a tech number. 17. Write a program to ask the user to input any number and print the largest and the smallest digit present in the number. 18. Write a menu driven program in Java to enter any number and print whether the number is a NIVEN number or an ARMSTRONG number as per the user s choice. A NIVEN number is one which is exactly divisible by the sum of its digits. Example : 42 is a Niven number (42 is exactly divisible by 4+2) A number is said to be ARMSTRONG if the sum of cube of the digits of the number is equal to the number. Example : Input = 153 ( 13 + 53 + 33) Output = 153 is an ARMSTRONG number. 19. Write a program in Java to print whether the number is a SPECIAL TWO-DIGIT number or not. A special two-digit number is such that when the sum of the digits is added to the product of the digits the result is equal to the original number. Example: 19,59 20. A computerised bus charges fare from each of its passengers based on the distance travelled as per the tariff given below : Distance (in km) Charges First 5 km Rs 80 Next 10 km Rs 10/km More than 15 km Rs 8/km As the passenger enters the bus, the computer prompts Enter distance you intend to travel . On entering the distance, it prints his ticket and the control goes back for the next passenger. When there are no more passengers -1 is entered as the distance. At the end of the journey, the computer prints the following: The number of passengers travelling Total fare received Write a program to perform the above task. PROGRAMS PROGRAM 1 //To enter any number between 1 to 9999 and print whether the number is one-digit, two-digit, three-digit or a four-digit number. import java.util.*; public class q_1 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int num; System.out.print("Enter any number between 1 to 9999:- "); num = sc.nextInt(); if (num < 1 ) //checking whether a program is less than 1 System.out.print("The number entered is lesser than '1'. "); else if (num > 9999) //checking whether the entered number is greater than 9999 System.out.print("The number entered is greater than '9999'. "); else if (num >= 1 && num <= 9) System.out.print("The number entered is a one-digit number. "); else if (num >= 10 && num <= 99) System.out.print("The number entered is a two-digit number. "); else if (num >= 100 && num <= 999) System.out.print("The number entered is a three-digit number. "); else if (num >= 1000 && num <= 9999) System.out.print("The number entered is a four-digit number. "); } //Close of Main Method } //Close of Class Variable Description Table Variable Name Variable Type Description num Used to store the number entered by the user int PROGRAM 2 //To print the total amount for the parcel import java.util.*; public class q_2 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); double w; System.out.print("Enter the weight of the parcel in kg's "); w = sc.nextDouble(); else if (w <=2) //checking the weight of the Parcel. System.out.print("Rs.100 for delivering the Parcel weighing "+w+" kg."); else if (w >=3 && w <= 6) //checking the weight of the Parcel. System.out.print("Rs.200 for delivering the Parcel weighing "+w+" kg."); else if (w > =7 && w < =10) //checking the weight of the Parcel. System.out.print("Rs.300 for delivering the Parcel weighing "+w+" kg."); else if (w > 10) //checking the weight of the Parcel. System.out.print("Rs.500 for delivering the Parcel weighing "+w+" kg."); } //Close of Main Method } //Close of Class Variable Description Table Variable Name Type Description w Used to store the weight of the parcel int PROGRAM 3 //To determine the roots of the equation after taking a, b and c as input. import java.util.*; public class q_3 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int a,b,c; double add, sub, d; System.out.print("The formation of a quadratic equation is:- "); System.out.println("ax2 + bx + c = 0"); System.out.print("Enter a: "); a = sc.nextInt(); System.out.print("Enter b: "); b = sc.nextInt(); System.out.print("Enter c: "); c = sc.nextInt(); d = Math.pow(b,2) - 4*a*c; if (d >= 0) { add = (-b + Math.sqrt(Math.pow(b,2) - 4 * a * c)) / (2 * a); sub = (-b - Math.sqrt(Math.pow(b,2) - 4 * a * c)) / (2 * a); System.out.print("The roots of the given quadratic equation are :"); System.out.print(add+", "); System.out.print(sub); } else System.out.println("The roots are Imaginary."); } } Variable Description Table Variabl Type e Name Description a int Used to store the value coefficients of x2 b int Used to store the value of coefficient of x. c int Used to store the value of the constant . d double Used to calculate and store the value of the discriminant. PROGRAM 4 //To print the charge for returning book late in a library import java.util.*; class COMP_PROJECT_4 { public static void main(String args[]) { Scanner sc= new Scanner(System.in); int d; double fine; System.out.print("Enter the number of days the book is returned late "); d=sc.nextInt(); if(d<=7) { fine =(double) d*1.50; System.out.print("The fine is "+fine); } if(d>7 && d<=14) { fine =(double)7*1.50 + (d-7)*2.50; System.out.print("The fine is "+fine); } if(d>14 && d<=24) { fine=(double)(7*1.50+7*2.50)+(d-14)*3.50; System.out.print("The fine is "+fine); } if(d>24) { fine=(double)(7*1.50+7*2.50+10*3.50)+(d-24)*5.50; System.out.print("The fine is "+fine); } }//close of main method }//close of class Variable Description Table Variable Name Type Description d int Used to store the number of days the book is returned late. fine double Used to calculate the fine to be paid PROGRAM 5 //To enter any number from 1 to 12 and print the corresponding month of the year. import java.util.*; public class q_5 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int num; System.out.println("Enter any number from 1 to 12. "); num = sc.nextInt(); switch (num) { case 1: System.out.println("The corresponding number to this month is:- January " ); System.out.print("It has total 31 days."); break; case 2: System.out.println("The corresponding number to this month is:-February" ); System.out.print("It has total 28 days."); break; case 3: System.out.println("The corresponding number to this month is:- March " ); System.out.print("It has total 31 days."); break; case 4: System.out.println("The corresponding number to this month is:- April " ); System.out.print("It has total 30 days."); break; case 5: System.out.println("The corresponding number to this month is:- May " ); System.out.print("It has total 31 days."); break; case 6: System.out.println("The corresponding number to this month is:- June " ); System.out.print("It has total 30 days."); break; case 7: System.out.println("The corresponding number to this month is:- July " ); System.out.print("It has total 31 days."); break; case 8: System.out.println("The corresponding number to this month is:- August " ); System.out.print("It has total 31 days."); break; case 9: System.out.println("The corresponding number to this month is:September " ); System.out.print("It has total 30 days."); break; case 10: System.out.println("The corresponding number to this month is:- October " ); System.out.print("It has total 31 days."); break; case 11: System.out.println("The corresponding number to this month is:November " ); System.out.print("It has total 30 days."); break; case 12: System.out.println("The corresponding number to this month is:December " ); System.out.print("It has total 31 days."); break; default: System.out.println( Wrong Input ) } } } Variable Description Table Variable Type Description Name num int Used to store the number entered by the user corresponding to the month of the year. PROGRAM 6 //To print whether a number entered is Prime or Perfect as per the user s choice. import java.util.*; public class q_6 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int num, opt, i, c=0, sum=0; System.out.print("Enter any number. "); num = sc.nextInt(); System.out.println("Enter 1 to check whether the number is Prime or not."); System.out.println("Enter 2 to check whether the number is Perfect or not."); opt = sc.nextInt(); switch (opt) { case 1: for (i =1; i<=num; i++) { if (num % i == 0) c ++; } //close of loop if (c==2) System.out.print(num+" is a Prime numbers."); else System.out.print(num+" is not a Prime number."); break; case 2: for (i =1; i<num; i++) { if (num % i == 0) sum = sum + i; } //close of loop if (sum == num) System.out.print("It is a Perfect number."); else System.out.print("It is not a Perfect number."); break; default: System.out.print("Invalid Input."); } } Variable Description Table Variable Type Description Name num int Used to store the number entered by the user. opt int Used to store the choice entered by the user as per the criteria. i int Provides a range of numbers from 1 to the entered number. c int Used to store the number of factors of the entered number. sum int Used to store the sum of the factors of the entered number. PROGRAM 7 //To input any 15 numbers (including positive and negative) and print as per the given criteria import java.util.*; public class q_7 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int num, p=0, sump=0, avgp=0, n=0, sumn=0, avgn=0, i; System.out.println("Enter any 15 numbers. "); for (i=0; i<15; i++) { num = sc.nextInt(); if (num > 0) { p++; sump = sump + num; avgp = (sump / p); } else if (num < 0) { n++; sumn = sumn + num; avgn = (sumn / n); } } System.out.println("The number of Positive numbers entered are: "+p); System.out.println("The number of Negative numbers entered are: "+n); System.out.println("The Sum of Positive numbers are: "+sump); System.out.println("The Sum of Negative numbers are: "+sumn); System.out.println("The Average of Positive numbers are: "+avgp); System.out.println("The Average of Negative numbers are: "+avgn); } } Variable Description Table Variable Name Type Description num int Used to store the numbers entered by the user. p int Used to store the number of positive numbers. i int To iterate the for-loop for calculation of positive and negative numbers. n int To calculate the number of negative integers. sump int To calculate and store the sum of positive numbers. sumn int To calculate and store the sum of negative numbers. avgp int To calculate and store the average of positive numbers. avgn int To calculate and store the average of negative numbers. PROGRAM 8 //To accept a number and check whether the number is Twisted Prime or not. import java.util.*; public class q_8 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int num ,rev = 0 ,ld ,temp, i, c=0; System.out.print("Enter any no."); num = sc.nextInt(); temp = num; while (temp != 0) { ld = temp % 10; rev = (rev * 10) +ld; temp = temp / 10; } for (i =1; i<=rev; i++) { if (rev % i == 0) c ++; } //close of loop if (c == 2) System.out.print(num +" is a Twisted number."); else System.out.print(num +" is not a Twisted number."); } } Variable Description Table Variable Name Type Description num int To store the number entered by the user. rev int To find and store the reverse value of the number. temp int To store the value of the entered number and iterate the whileloop. c int To count and store the number of factors of the reversed number. i int To iterate the for-loop for calculating the number of factors of the reversed number. ld int To find and store the last digit of the number. PROGRAM 9 //To print all pronic numbers from 1 to 1000 import java.util.*; class COMP_PROJECT_9 { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n,f=0,i; for(n=1;n<=1000;n++) { for(i=0;i<n;i++) { if(i*(i+1) == n) { f=1; break; } } if(f==1) { System.out.println(n); } f=0; } } } Variable Description Table Variable Type Description Name n int To iterate the for-loop for calculating and printing all pronic numbers from 1 to 1000. i int To iterate the for-loop for finding whether the number is pronic or not. f int To break the loop whenever the number is a pronic number PROGRAM 10 //To enter any number and print whether the number is a CYCLO number or TWIST number as per the user s choice. import java.util.*; class COMP_PROJECT_10 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int ch,num,ld; System.out.println("Enter 1 to check whether the entered number is a CYCLO number or not"); System.out.println("Enter 2 to check whether the entered number is a TWIST number or not"); System.out.println("Enter your choice"); ch=sc.nextInt(); System.out.print("Enter any number"); switch(ch) { case 1 : num = sc.nextInt(); ld=num%10; while(num>9) { num=num/10; } if(ld==num) { System.out.print("It is a CYCLO number"); } else { System.out.print("It is not a CYCLO number"); } break; case 2 : num = sc.nextInt(); ld=num%10; while(num>9) { num=num/10; } if(num%2!=0 && ld%2==0) { System.out.print("It is a TWIST number"); } else { System.out.print("It is not a TWIST number"); } break; default : System.out.println("INVALID INPUT"); break; } } } Variable Description Table Variable Name Type Description num int To store the number entered the user. ch int To store the choice entered by the user. ld int To find and store the last digit of the number. PROGRAM 11 // To print whether the no. is an ISBN no. or not import java.util.*; class ISBN_No { public static void main(String args[]) { Scanner sc=new Scanner(System.in); long num,i,ld,p,sum=0; System.out.print("Enter any no."); num=sc.nextLong(); if(num>=1000000000L && num<=9999999999L) { System.out.println("It is a 10-digit no."); for(i=10;i>=1;i--) { ld=num%10; p=ld*i; sum+=p; num=num/10; } if(sum%11==0) { System.out.print("Legal ISBN"); } else { System.out.print("Illegal ISBN"); } } else { System.out.println("Illegal ISBN no."); } }//close of main method }//close of class Variable Description Table Variable Type Description Name num int To store the ISBN code entered by the user. i int To iterate the for loop for finding whether the entered number is an ISBN number or not. p int To find the factorial of entered number. sum int To find the sum of factorial of entered number. PROGRAM 12 .//To check whether a given number is an AUTOMORPHIC number or not. import java.util.*; public class q_12 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int num,t ,d=0 ,r ,sq; System.out.print("Enter any no. "); num = sc.nextInt(); t = num; sq = num*num; while(t!=0) { d++; t/= 10; } r = sq % (int)Math.pow (10,d); if(r==num) System.out.print(num+" is an Automorphic no."); else System.out.print(num+" is not an Automorphic no."); } //close of main method }//close of class Variable Description Table Variable Name Type Description num int To store the number entered by the user. t int To iterate the while loop for calculating the number of digits in the number. d int To store the number of digits in the number. r int To find and store the number from the last digit of its square. PROGRAM 13 .// To print sum of series as per user s choice import java.util.*; class Sum_Series_menudriven { public static void main (String args[]) { Scanner sc=new Scanner (System.in); int ch,i,sum=0; System.out.println ("Enter 1 for sum of first series"); System.out.println ("Enter 2 for sum of second series"); ch=sc.nextInt(); switch(ch) { case 1:for(i=1;i<=10;i++) { sum+=i*i-1; } System.out.println("Sum of series="+sum); break; case 2:for(i=2;i<=20;i+=2) { if(i%4!=0) sum+=i; else if(i%4==0) sum-=i; } System.out.println("Sum of series="+sum); break; default:System.out.println ("Wrong Input"); } }//close of main method }//close of class Variable Description Table Variable Name Type Description ch int To store the choice entered by the user. i int To iterate the for-loop for generating the series. sum int To store the sum of the generated series. PROGRAM 14 // To print sum of series as per user s choice import java.util.*; class Sum_Series_menudriven { public static void main (String args[]) { Scanner sc=new Scanner (System.in); int ch,i,n,x; double s=0.0; System.out.println ("Enter 1 for sum of first series"); System.out.println ("Enter 2 for sum of second series"); ch=sc.nextInt(); switch(ch) { case 1:for(i=1;i<=9;i++) { s+=(double)i/(i+1); } System.out.println("Sum of series="+sum); break; case 2:System.out.println ("Enter value of n"); n=sc.nextInt(); System.out.println ("Enter value of x"); x=sc.nextInt(); for(i=1;i<=n;i+=2) { s+=Math.pow(x,i)/(i+1); } System.out.println("Sum of series="+s); break; default:System.out.println ("Wrong Input"); } }//close of main method }//close of class Variable Description Table Variable Name Type Description ch int To store the choice entered by the user. i int To iterate the for-loop for generating the seris. s double To store the sum of the generated series n int To store value of n in the series. x int To store value of x in the series. PROGRAM 15 /** To print the patterns as per the user s choice. 1 1 12 33 123 555 1234 7777 12345 99999 */ import java.util.*; class Pattern_Choice { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int ch; System.out.println("Enter 1 for generating the 1st patter and 2 for generating the 2nd pattern "); ch=sc.nextInt(); switch(ch) { case 1:int i,j; for(i=1;i<=5;i++) { for(j=1;j<=i;j++) System.out.print(j+" "); System.out.println(); } break; case 2:for(i=1;i<=9;i+=2) { for(j=1;j<=i;j+=2) System.out.print(i+" "); System.out.println(); } break; default: System.out.println(" Wrong input "); } } } Variable Description Table Variable Name Type Description ch int To store the choice entered by the user. i int To iterate the for loop for generating the series. j int To iterate the nested for-loop for generate the series. PROGRAM 16 //To print and generate all four digit tech numbers. import java.util.*; public class q_16 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int n, ld, fd, sum, sq; System.out.println("All four-digit Tech numbers are:- "); for( n = 1000; n <= 9999 ; n++) { ld = n % 100; fd = n / 100; sum = fd + ld; sq = sum * sum; if ( sq == n) System.out.println(n); } } //close of main method }//close of class Variable Description Table Variable Name Type Description n int To iterate the for-loop for generating all four digit numbers. ld int To store the last two digits of the number. fd int To store the first two digits of the number. sum int To find and store the sum of first two digits and last two digits of the number. sq int To find and store the square of the sum. PROGRAM 17 // To print the largest and the smallest digit present in the number import java.util.*; class COMP_PROJECT_17 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int num, max=0,min=9,ld; System.out.print("Enter any number"); num=sc.nextInt(); while(num!=0) { ld = num%10; if(ld>max) { max = ld; } else if(ld<min) { min = ld; } num=num/10; } System.out.println("Largest digit:" + max); System.out.print("Smallest digit:" + min); } } Variable Description Table Variabl Type e Name Description num int To store the number entered by the user. ld int To store the last digit of the number. max int To store the largest digit of the number. min int To store the smallest digit of the number. PROGRAM 18 //To print whether the entered number is NIVEN or ARMSTRONG as per the user's choice import java.util.*; class COMP_PROJECT_18 { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int ch,num,temp,ld,sum=0,cu; System.out.println("Enter 1 to check whether the number entered is NIVEN or not"); System.out.println("Enter 2 to check whether the number entered is ARMSTRONG or not"); System.out.println("Enter your choice"); ch = sc.nextInt(); System.out.print("Enter any number"); switch(ch) { case 1: num=sc.nextInt(); temp=num; while(num!=0) { ld=num%10; sum=sum+ld; num=num/10; } if(temp%sum==0) { System.out.print("It is a NIVEN number"); } else { System.out.print("It is not a NIVEN number"); } break; case 2: num=sc.nextInt(); temp=num; while(num!=0) { ld=num%10; cu=ld*ld*ld; sum+=cu; num = num/10; } if(sum==temp) { System.out.print("It is an ARMSTRONG number"); } else { System.out.print("It is not an ARMSTRONG number"); } break; default: System.out.println("WRONG INPUT"); break; } } } Variable Description Table Variable Type Name Description num int To store the number entered by the user. temp int To store the value of num . ch int To store the choice entered by the user. ld int To store the last digit of the number. cu int To find and store the cube of each digit of the number. sum int To find and store the sum of cube of each digit of the number. PROGRAM 19 //To print whether the number is a SPECIAL TWO-DIGIT number or not. import java.util.*; public class q_19 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int num, ld, temp=0, sum=0, pro=1; System. out.print("Enter a number. "); num = sc.nextInt(); temp = num; while (num != 0) { ld = num % 10; sum = sum + ld; pro = pro * ld; num = num / 10; } if (sum + pro == temp) System.out.print(num +" is a special two-digit number. "); else System.out.print(num +" is not a special two-digit number."); } } Variable Description Table Variable Name Type Description num int To store the number entered by the user. temp int To store the value of num . sum int To calculate and store the sum of the digits of the number. pro int To find and store the product of the digits of the number. ld int To find and store the last digit of the number. PROGRAM 20 //To record a bus journey import java.util.*; class COMP_PROJECT_20 { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int d,c=0,fare,sum=0; while(true) { System.out.println("Enter distance you intend to travel"); d=sc.nextInt(); if(d!=-1) { c++; if(d<=5) { fare=80; sum=sum+fare; } else if(d>5 && d<=15) { fare=80+(d-5)*10; sum=sum+fare; } else if(d>15) { fare = 180+(d-15)*8; sum=sum+fare; } } fare=0; if(d==-1) { System.out.println("Number of passengers travelling is "+c); System.out.println("Total fare received is "+sum); break; } } } } Variable Description Table Variabl Type Description e Name d int To store the distance entered by the user. fare int To calculate the fare for the distance to be travelled. sum int To calaculate and store the total fare. c int To find and store the total passengers travelling.

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

 

  Print intermediate debugging step

Show debugging info


 

 

© 2010 - 2025 ResPaper. Terms of ServiceContact Us Advertise with us

 

rrrrrr28562546552 chat