0% found this document useful (0 votes)
5 views4 pages

Java 30 Programs Project Full

The document outlines two Java programs for a school project. The first program captures and displays the roll numbers, marks, and names of five students, while the second program modifies a string by converting each character to its opposite case and shifting it circularly by one character. Each program includes code, variable lists, and algorithms detailing their functionality.

Uploaded by

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

Java 30 Programs Project Full

The document outlines two Java programs for a school project. The first program captures and displays the roll numbers, marks, and names of five students, while the second program modifies a string by converting each character to its opposite case and shifting it circularly by one character. Each program includes code, variable lists, and algorithms detailing their functionality.

Uploaded by

balameh429
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Java 30 Programs - School Project

Program 1
Question: Write a program to input 5 students' roll numbers, marks and names, and display
them.

Code:

import [Link];
class selectionsort {
void display() {
Scanner sc = new Scanner([Link]);
int arr[] = new int[5];
int roll[] = new int[5];
String name[] = new String[5];
[Link]("Array elements");
for(int i=0;i<5;i++) {
arr[i] = [Link]();
roll[i] = [Link]();
}
[Link]("Enter names");
for(int i=0;i<5;i++) {
name[i] = [Link]();
}
for(int i=0;i<5;i++) {
[Link](arr[i]);
[Link](name[i]);
[Link](roll[i]);
}
}
}

Variable List:

Variable Type Purpose

arr int[] Stores marks of 5 students

roll int[] Stores roll numbers of 5


students
name String[] Stores names of 5 students

sc Scanner Scanner object for input

Algorithm:

1. Start the program and initialize Scanner object.

2. Declare arrays for marks, roll numbers, and names of size 5.

3. Input marks and roll numbers for each student.

4. Input names of each student.

5. Display the marks, names, and roll numbers.


Program 2
Question: Write a program to input a string, convert each character to opposite case and
shift circularly by 1 character.

Code:

import [Link];
class stringop {
String Txt;
stringop() { Txt=""; }
void readstring() {
Scanner sc = new Scanner([Link]);
[Link]("Enter a string");
Txt = [Link]();
}
char caseconvert(char c) {
if([Link](c)) c = [Link](c);
else if([Link](c)) c = [Link](c);
return c;
}
void circulardecode() {
int l = [Link]();
String n = "";
for(int i=0;i<l;i++) {
char x = [Link](i);
x = caseconvert(x);
int b = (int) x;
if((b>=65 && b<=89)||(b>=97 && b<=121)) x=(char)(b+1);
else if(b==90) x='A';
else if(b==122) x='a';
n = n + x;
}
[Link]("Modified string: " + n);
}
void main() {
stringop obj = new stringop();
[Link]();
[Link]();
}
}
Variable List:

Variable Type Purpose

Txt String Stores input string

sc Scanner Scanner object for input

n String Stores modified string

x char Stores character during


processing

b int ASCII value of character

Algorithm:

1. Start the program and initialize Scanner.

2. Input string into Txt.

3. For each character in Txt, convert its case.

4. Shift character circularly by 1 position.

5. Append to new string n.

6. Display the modified string.

You might also like