Computer project
Computer project
System.out.println("2. Press 2 to convert binary to integer when fractional part is not 0.");
System.out.println("4. Press 4 to convert octal to integer when fractional part is not 0.");
int x = sc.nextInt();
switch (x) {
case 1:
int x1 = sc.nextInt();
x1 = Math.abs(x1);
break;
case 2:
double x2 = sc.nextDouble();
int k = sc.nextInt();
x2 = Math.abs(x2);
k = Math.abs(k);
break;
case 3:
int x3 = sc.nextInt();
x3 = Math.abs(x3);
break;
case 4:
double x4 = sc.nextDouble();
int k2 = sc.nextInt();
x4 = Math.abs(x4);
k2 = Math.abs(k2);
break;
default:
System.out.println("Invalid input.");
}
Start
Input Initialization
Read Sentences
4. Initialize a counter f to 0.
3. If x is a palindrome:
Handle No Palindromes
1. If the counter f is 0:
Print Frequency
1. If the counter f is greater than 0:
End
Second program
1. Start
2. Input Initialization
1. Initialize a boolean variable isSorteda to true (to check if the array is sorted in ascending
order).
2. Initialize a boolean variable isSortedd to true (to check if the array is sorted in descending
order).
1. If a[i] > a[i+1], set isSorteda to false and break the loop.
1. If a[i] < a[i+1], set isSortedd to false and break the loop.
5. Output Result
1. If isSorteda or isSortedd is true:
2. Else:
1. If a[j+1] < a[j], swap the elements a[j+1] and a[j] without
using a temporary variable.
6. End
1. Start
2. Input Initialization
1. Set s to a[i].
1. Set s to a[j].
3. Set b[i] to s.
6.End
1 Start
2 Input: Read the number n from the user.
3 Loop: Iterate over possible values of i from 1 to n/2:
Loop: Iterate over possible values of j from 1 to n/2:
o Check: If i*i*i + j*j*j == n
Output: Print n + " = " + i + "^3 +" + j + "^3"
Output: Print "Hence a Ramanujan number"
Terminate the program
4 Output: Print "Not a Ramanujan number"
5 End
Algo for 7th prog
1. DayNo Function
Algorithm:
1. Start
3. If-Else Conditions:
o If x is 9, 4, 6, or 11:
o Else If x is 2:
4. End
2. main Function
Purpose: To calculate and print the age and remaining time between two dates.
Algorithm:
1. Start
2. Input:
o Year of birth y
o Month of birth m
o Day of birth d
o Current year y2
o Current month m2
o Current day d2
3. Validation:
o If y2 < y (current year is before birth year) or y2 < 1903 (invalid year) or m < 1 or m
> 12 (invalid birth month) or m2 < 1 or m2 > 12 (invalid current month) or d2 >
DayNo(m2) (invalid current day) or d > DayNo(m) (invalid birth day):
4. Calculate Age:
o If m2 >= m (current month is the same or after birth month):
Age in years = y2 - y
Age in years = y2 - y - 1
Remaining months = 0
Remaining days = d2 - d
Remaining months = 11
Remaining months = m2 - m
Remaining days = d2 - d
Remaining months = m2 - m - 1
7. End
Algo for 8th prog
Start
Preprocessing:
Count Words:
Initialize n to 0.
o Move to the next word position by updating i to the index of the next space or the
end of the string.
Initialize:
Initialize index k to 0.
Extract Words:
Assign w to wo[k].
Increment k.
Sort Words:
o Assume max is i.
If the length of wo[max] is less than the length of wo[j], update max to j.
o If max is not i:
Output:
End
Algo for 9th prog
Start
Preprocessing:
Count Words:
Initialize n to 0.
o Increment n.
o Update i to the index of the next space or the end of the string.
Initialize Arrays:
Initialize variable k to 0.
Extract Words:
Assign w to wo[k].
Increment k.
o Set max to i.
If the length of wo[max] is less than the length of wo[j], update max to j.
Output:
Print "Words in descending length: ".
End
1. Start
2. Input:
3. Initialize Matrix:
5. Mirror Matrix:
7. End