Skip to content

Commit a7396b0

Browse files
committed
update
1 parent 590da56 commit a7396b0

33 files changed

+210
-338
lines changed

Diff for: Aula1.java

-19
This file was deleted.

Diff for: Practical/Class2-P/Problem1.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import java.util.Scanner;
22
public class Problem1 {
3-
public static void main(String[] args) {
4-
Scanner scan = new Scanner(System.in);
5-
int x, res;
6-
x = scan.nextInt();
7-
if (x < 0){
8-
x = - x;
9-
}
10-
res = x*3;
11-
System.out.print(res);
12-
}
3+
public static void main(String[] args) {
4+
Scanner scan = new Scanner(System.in);
5+
int x, res;
6+
x = scan.nextInt();
7+
if (x < 0){
8+
x = - x;
9+
}
10+
res = x*3;
11+
System.out.print(res);
12+
}
1313
}

Diff for: Practical/Class2-P/Problem10.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import java.util.Scanner;
22
import java.lang.Math;
33
public class Problem10 {
4-
public static void main(String[] args) {
5-
System.out.println("Here's one random number: " + Math.random());
6-
}
4+
public static void main(String[] args) {
5+
System.out.println("Here's one random number: " + Math.random());
6+
}
77
}

Diff for: Practical/Class2-P/Problem2.java

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import java.util.Scanner;
22
public class Problem2 {
3-
public static void main(String[] args) {
4-
Scanner scan = new Scanner(System.in);
5-
int age;
6-
age = scan.nextInt();
7-
if(age < 5){
8-
System.out.print("Not avaliable.");
9-
}
10-
else if (age <=7){
11-
System.out.print("InfantA");
12-
}
13-
else if (age<=11){
14-
System.out.print("InfantB");
15-
}
16-
else if(age <= 13){
17-
System.out.print("JuvenileA");
18-
}
19-
else if(age <= 17){
20-
System.out.print("JuvenileB");
21-
}
22-
else{
23-
System.out.print("Adults");
24-
}
25-
}
3+
public static void main(String[] args) {
4+
Scanner scan = new Scanner(System.in);
5+
int age;
6+
age = scan.nextInt();
7+
if(age < 5){
8+
System.out.print("Not avaliable.");
9+
}
10+
else if (age <=7){
11+
System.out.print("InfantA");
12+
}
13+
else if (age<=11){
14+
System.out.print("InfantB");
15+
}
16+
else if(age <= 13){
17+
System.out.print("JuvenileA");
18+
}
19+
else if(age <= 17){
20+
System.out.print("JuvenileB");
21+
}
22+
else{
23+
System.out.print("Adults");
24+
}
25+
}
2626
}

Diff for: Practical/Class2-P/Problem3.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import java.util.Scanner;
22
public class Problem3{
3-
public static void main(String[] args) {
4-
Scanner scan = new Scanner(System.in);
5-
double avg;
6-
avg = scan.nextDouble();
7-
if (avg < 4){
8-
System.out.print("You failed.");
9-
}
10-
else if(avg < 7){
11-
System.out.print("You can do the recovery exam.");
12-
}
13-
else{
14-
System.out.print("You passed.");
15-
}
16-
}
3+
public static void main(String[] args) {
4+
Scanner scan = new Scanner(System.in);
5+
double avg;
6+
avg = scan.nextDouble();
7+
if (avg < 4){
8+
System.out.print("You failed.");
9+
}
10+
else if(avg < 7){
11+
System.out.print("You can do the recovery exam.");
12+
}
13+
else{
14+
System.out.print("You passed.");
15+
}
16+
}
1717
}

Diff for: Practical/Class2-P/Problem4.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import java.util.Scanner;
22
import java.lang.Math;
33
public class Problem4 {
4-
public static void main(String[] args) {
5-
Scanner scan = new Scanner(System.in);
6-
int x;
7-
x = scan.nextInt();
8-
System.out.print("|" + x + "| = " + Math.abs(x));
9-
}
4+
public static void main(String[] args) {
5+
Scanner scan = new Scanner(System.in);
6+
int x;
7+
x = scan.nextInt();
8+
System.out.print("|" + x + "| = " + Math.abs(x));
9+
}
1010
}

Diff for: Practical/Class2-P/Problem5.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import java.util.Scanner;
22
import java.lang.Math;
33
public class Problem5 {
4-
public static void main(String[] args) {
5-
Scanner scan = new Scanner(System.in);
6-
double x;
7-
x = scan.nextDouble();
8-
System.out.println(x + " is approximately " + Math.round(x));
9-
System.out.print("The ceiling of " + x + " is " + Math.ceil(x));
10-
}
4+
public static void main(String[] args) {
5+
Scanner scan = new Scanner(System.in);
6+
double x;
7+
x = scan.nextDouble();
8+
System.out.println(x + " is approximately " + Math.round(x));
9+
System.out.print("The ceiling of " + x + " is " + Math.ceil(x));
10+
}
1111
}

Diff for: Practical/Class2-P/Problem6.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import java.util.Scanner;
22
import java.lang.Math;
33
public class Problem6 {
4-
public static void main(String[] args) {
5-
Scanner scan = new Scanner(System.in);
6-
double x;
7-
x = scan.nextDouble();
8-
System.out.println("The floor of " + x + " is " + Math.floor(x));
9-
}
4+
public static void main(String[] args) {
5+
Scanner scan = new Scanner(System.in);
6+
double x;
7+
x = scan.nextDouble();
8+
System.out.println("The floor of " + x + " is " + Math.floor(x));
9+
}
1010
}

Diff for: Practical/Class2-P/Problem7.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import java.util.Scanner;
22
import java.lang.Math;
33
public class Problem7 {
4-
public static void main(String[] args) {
5-
Scanner scan = new Scanner(System.in);
6-
double x, y;
7-
x = scan.nextDouble();
8-
y = scan.nextDouble();
9-
System.out.println("min(" + x + ", " + y + ") is " + Math.min(x, y));
10-
System.out.println("max(" + x + ", " + y + ") is " + Math.max(x, y));
11-
}
4+
public static void main(String[] args) {
5+
Scanner scan = new Scanner(System.in);
6+
double x, y;
7+
x = scan.nextDouble();
8+
y = scan.nextDouble();
9+
System.out.println("min(" + x + ", " + y + ") is " + Math.min(x, y));
10+
System.out.println("max(" + x + ", " + y + ") is " + Math.max(x, y));
11+
}
1212
}

Diff for: Practical/Class2-P/Problem8.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import java.util.Scanner;
22
import java.lang.Math;
33
public class Problem8 {
4-
public static void main(String[] args) {
5-
Scanner scan = new Scanner(System.in);
6-
double x, y;
7-
x = scan.nextDouble();
8-
y = scan.nextDouble();
9-
System.out.println("pow(x, y) is " + Math.pow(x, y));
10-
}
4+
public static void main(String[] args) {
5+
Scanner scan = new Scanner(System.in);
6+
double x, y;
7+
x = scan.nextDouble();
8+
y = scan.nextDouble();
9+
System.out.println("pow(x, y) is " + Math.pow(x, y));
10+
}
1111
}

Diff for: Practical/Class2-P/Problem9.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import java.util.Scanner;
22
import java.lang.Math;
33
public class Problem9 {
4-
public static void main(String[] args) {
5-
Scanner scan = new Scanner(System.in);
6-
double x;
7-
x = scan.nextDouble();
8-
System.out.println("The square root of " + x + " is " + Math.sqrt(x));
9-
}
4+
public static void main(String[] args) {
5+
Scanner scan = new Scanner(System.in);
6+
double x;
7+
x = scan.nextDouble();
8+
System.out.println("The square root of " + x + " is " + Math.sqrt(x));
9+
}
1010
}

Diff for: Practical/Class3-P/Problem1.class

-739 Bytes
Binary file not shown.

Diff for: Practical/Class3-P/Problem2.java

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import java.util.Scanner;
2+
public class Problem2{
3+
public static void main(String[] args){
4+
Scanner scan = new Scanner(System.in);
5+
int value, nc = 0, nt = 0, nf = 0, no = 0, rc, rt, rf, ro;
6+
do {
7+
System.out.println("How much will you draw");
8+
value = scan.nextInt();
9+
}while(value < 0 || value > 2000);
10+
nc = value/50;
11+
rc = value%50;
12+
nt = rc/10;
13+
rt = value%10;
14+
nf = rt/5;
15+
rf = value%5;
16+
no = rf/1;
17+
ro = value%1;
18+
System.out.print("You will recieve: " + nc + " notes of 50, " + nt + " notes of 10, " + nf + " notes of 5 and " + no + "notes of 1.");
19+
}
20+
}

Diff for: Practical/Class3-P/Problem3.java

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import java.util.Scanner;
2+
public class Problem3 {
3+
public static void main(String[] args) {
4+
Scanner scan = new Scanner(System.in);
5+
int N = 1;
6+
while(N > 0){
7+
N = scan.nextInt();
8+
if ( N < 0){
9+
break;
10+
}
11+
else if ( N%2 == 0){
12+
System.out.println(N + " is even.");
13+
}
14+
else if ( N < 0){
15+
break;
16+
}
17+
else{
18+
System.out.println(N + " is odd.");
19+
}
20+
}
21+
}
22+
}

Diff for: Practical/Class3-P/Problem4.java

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public class Problem4 {
2+
public static void main(String[] args) {
3+
int num = 2, rest, y;
4+
while ( num < 50000){
5+
int a = 0;
6+
for(y = 1 ; y < num ; y++){
7+
rest = num%y;
8+
if(rest == 0){
9+
a = a + y;
10+
}
11+
}
12+
if ( a == num){
13+
System.out.println(num + "perfect");
14+
}
15+
num++;
16+
}
17+
}
18+
}

Diff for: Practical/Class3-P/Problem5.java

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.Scanner;
2+
public class Problem5{
3+
public static void main(String[] args){
4+
Scanner scan = new Scanner(System.in);
5+
int num, div, y, x, prime, max, rest;
6+
prime = max = 0;
7+
num = scan.nextInt();
8+
for ( y = 2; y <= num; y++){
9+
div = 0;
10+
for(x = 2; x<= y; x++){
11+
rest = y%x;
12+
if( rest == 0){
13+
div = div + x;
14+
}
15+
}
16+
if(div == y){
17+
prime = y;
18+
}
19+
if(max < prime){
20+
max = prime;
21+
}
22+
}
23+
System.out.print("The last prime number is " + max);
24+
}
25+
}

Diff for: Practical/Class6-P/Problem1.class

815 Bytes
Binary file not shown.

Diff for: Practical/Class6-P/Problem1.java

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import java.util.Scanner;
2+
import java.util.Arrays;
3+
public class Problem1{
4+
public static void main(String[] args) {
5+
Scanner scan = new Scanner(System.in);
6+
int V[] = new int[10];
7+
int B[] = new int[5];
8+
int j = 0;
9+
for(int i = 0; i < 10; i++){
10+
System.out.print("Put a value: ");
11+
V[i] = scan.nextInt();
12+
if(i%2 == 0){
13+
B[j] = V[i];
14+
j++;
15+
}
16+
}
17+
System.out.print(Arrays.toString(B));
18+
}
19+
}

Diff for: Practical/Class6-P/Problem2.class

1.19 KB
Binary file not shown.

Diff for: Practical/Class6-P/Problem2.java

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import java.util.Arrays;
2+
import java.util.Scanner;
3+
public class Problem2{
4+
public static void main(String[] args) {
5+
Scanner scan = new Scanner(System.in);
6+
String v[] = new String[2];
7+
String f[] = new String[2];
8+
int j = 1;
9+
for(int i = 0; i < 2; i++){
10+
v[i] = scan.nextLine();
11+
v[i] = f[j];
12+
j--;
13+
}
14+
System.out.print(Arrays.toString(f));
15+
}
16+
}

Diff for: Practical/Class6-P/Problem3.java

Whitespace-only changes.

Diff for: Practical/Class6-P/Problem4.java

Whitespace-only changes.

Diff for: Practical/Class6-P/Problem5.java

Whitespace-only changes.

Diff for: Practical/Class6-P/Problem6.java

Whitespace-only changes.

Diff for: Practical/Class6-P/Problem7.java

Whitespace-only changes.

0 commit comments

Comments
 (0)