Professional Documents
Culture Documents
Computer Project by Devasya Bansal
Computer Project by Devasya Bansal
Computer Project by Devasya Bansal
By
Devasya Bansal
Class : 10
Section : C
Roll No. : 16
Session : 2023 – 2024
Acknowledgement
I would like to thank my Computer teacher Mr. M. Alsam for
his valuable guidance and help. He clarified all my queries
about the project without which I would have not been able to
complete the project. I would also like to thank my family for
providing all necessary materials and my friends for helping me
with this project.
Assignment programs :
Program 1 Write a program using Java language to calculate total number of
vowels and consonants present in the given string.
import java.util.*;
int v = 0;
int c = 0;
int i = 0;
int l = word.length();
char ch = word.charAt(i);
switch(ch)
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
System.out.println("There are " +v +" vowels and " +c +" consonants in " +word);
import java.util.Scanner;
public class Vertical
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the word ");
String word = sc.nextLine(); //to input the word given by the user
int i; //to iterate the for loop
int l= word.length(); //to indicate the no. of letters in the word
word = word.toUpperCase(); //to change the letters to Uppercase
for(i=0; i<l; i++)
{
System.out.println("\t"+word.charAt(i)); //to print each letter of the word
}
}
}
import java.util.Scanner;
public class Grade
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the marks obtained in Computer Applications (out of 100): ");
int marks = sc.nextInt();
int percentage = marks; //since they are out of 100
char grade;
switch (percentage / 5) //switch expression
{
//case statements
case 20:
case 19:
case 18:
case 17:
case 16:
case 15:
grade = 'A';
break;
case 14:
case 13 :
case 12:
grade = 'B';
break;
case 11:
case 10:
case 9 :
case 8 :
grade = 'C';
break;
default: grade = 'D'; //will print D grade if marks are less than 40
break;
}
System.out.println("Grade obtained: " + grade);
}
}
import java.util.Scanner;
public class Calculator
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int num1 = sc.nextInt(); // First random number
int num2 = sc.nextInt(): // Second random number
int num3 = sc.nextInt(); // Third random number
int choice;
do
{
System.out.println("Menu:"); // Display the menu
System.out.println("1. Calculate Sum");
System.out.println("2. Calculate Product");
System.out.println("3. Calculate Average");
System.out.println("4. Exit");
System.out.print("Enter your choice: ");
choice = scanner.nextInt();
switch (choice)
{
case 1: int sum = num1 + num2 + num3; //to calculate the sum
System.out.println("Sum: " + sum);
break;
case 2: int product = num1 * num2 * num3; //to calculate the product
System.out.println("Product: " + product);
break;
case 3: double average = (num1 + num2 + num3) / 3.0;
//to calculate the average
System.out.println("Average: " + average);
break;
case 4: System.out.println("Exiting the program.");
break;
default : System.out.println("Invalid choice. Please enter a valid option.");
break;
}
}
while (choice != 4);
}
}
import java.util.*;
switch(number)//Switch expression
//Case statements
case 1: System.out.println("Sunday");
break;
case 2: System.out.println("Monday");
break;
case 3: System.out.println("Tuesday");
break;
case 4: System.out.println("Wednesday");
break;
case 5: System.out.println("Thursday");
break;
case 6: System.out.println("Friday");
break;
case 7: System.out.println("Saturday");
break;
55555
4444
333
22
1
import java.util.Scanner;
int i = 0;
int l = word.length();
else
System.out.print(+b +" " +c); //to print the first two digits
import java.util.*;
int i;
import java.util.Scanner;
public class Student
{
private String name;
private int age;
private int m1, m2, m3;
private int maximum;
private double average;
public void compute() //This method computes the average and the maximum
out of three numbers
{
maximum = Math.max(m1, Math.max(m2, m3)); //calculates the maximum of
the three no.s
average = (m1 + m2 + m3) / 3.0;
}
import java.util.Scanner;
public class EvenOdd
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int[] numbers = new int[10];
int evenCount = 0;
int oddCount = 0;
System.out.println("Enter 10 numbers:");
for (int i = 0; i < 10; i++)
{
numbers[i] = sc.nextInt(); //takes 10 different numbers
}
System.out.println("Even numbers:");
for (int i = 0; i < 10; i++)
{
if (numbers[i] % 2 == 0) //checks whether number is even or not
{
System.out.println(numbers[i]);
evenCount++; //calculates the amount of even numbers
}
}
System.out.println("Total even numbers: " + evenCount);
System.out.println("Odd numbers:");
for (int i = 0; i < 10; i++)
{
if (numbers[i] % 2 != 0) //checks whether number is odd or not
{
System.out.println(numbers[i]);
oddCount++; //calculates the amount of odd numbers
}
}
System.out.println("Total odd numbers: " + oddCount);
}
}
import java.util.*;
int i = 0;
int smallest = num[i]; // Initialize variables to store the largest and smallest
numbers
for (i = 0; i < 20; i++) // Find the largest and smallest numbers in the array
largest = num[i];
smallest = num[i];
}
3 largest Integer To find and store the largest no. in the array
Member functions: Input( ) store the pan number, name, taxable income
calc( ) calculate tax for an employee
display( ) output details of an employee
Write a program using Java language to compute the tax according to the given
conditions and display the output as per given format:
import java.util.Scanner;
import java.util.Scanner;
public class Reverse
{
public static void main (String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Please enter a Word");
String word = sc.nextLine(); //to take the input
String rev = "";
word = word.toUpperCase(); //to change the word to upper case
int i = 0;
int l = word.length();
for(i=l-1; i>=0; i--)
{
rev = rev + word.charAt(i); //to get the reversed word
}
System.out.println("The reversed word : " +rev);
}
}
for (int i =1; i<20; i+=2) // Increment i by 2 to get the next odd number
System.out.println("Sum of the squares of the first ten odd numbers is : " + sum);
import java.util.Scanner;
import java.util.Scanner;
// Split the input string into words using spaces as delimiters and return the count of
words
import java.util.Scanner;
public class SevenCount
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int[] arr = new int[10]; // Declare an array to store 10 numbers
int count = 0;
System.out.println("Enter 10 numbers:");
for (int i = 0; i < arr.length; i++) //reads input from the user
{
arr[i] = sc.nextInt();
if (arr[i] == 7)
{
count++; // to count the occurrences of the number in an array
}
}
Program 20 Write a program using Java language to convert the given decimal number
into binary number.
import java.util.Scanner;
int decimal = sc.nextInt(); //get the decimal number from the user
Write a program using Java language to calculate total number of vowels and 1-2
1.
consonants present in the given string.
Write a program using Java language to display the given string in the vertical
2. 3
manner.
Write a program using Java language to verify whether the entered number is
5. divisible by 8 or not. Display an appropriate message. The program must stop 8
when the number 0 is entered from the keyboard.
Write a program using Java language to display the weekdays as per the
6. numbers entered from the keyboard. The entered numbers should be between 9-10
1and 7.
Write a program using Java language to enter a string and check whether it is a
8. 12-13
Palindrome or not.
14. 23-25
Write a program using Java language to input a string and then display it in the
reverse order.
15. 26
Write a program using Java language to display the sum of the squares of first
ten odd numbers.
16. 27
Write a program using Java language to display the sum of the squares of first
ten odd numbers.
17. 28
Write a program using Java language to input a string and the replace all the
vowels of this string with ‘Z’.
18. 29
Write a program using Java language to input a string and then display the
total number of words in this string.
19. 30
Write a program using Java language to look for number 7 in an array of 10
numbers. Also count how many times it occurs in the array.
20. 31
Write a program using Java language to convert the given decimal number
into binary number.