0% found this document useful (0 votes)
4 views

java program (1)

The document contains Java code for three different programs. The first program checks if a number is abundant, the second generates a Tribonacci series and a specific mathematical series, and the third finds the maximum and minimum from 15 input numbers. Each program utilizes user input and loops to perform calculations and display results.

Uploaded by

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

java program (1)

The document contains Java code for three different programs. The first program checks if a number is abundant, the second generates a Tribonacci series and a specific mathematical series, and the third finds the maximum and minimum from 15 input numbers. Each program utilizes user input and loops to perform calculations and display results.

Uploaded by

vanshchess404
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

import java.util.

*;
class program1{
public static void main(){
Scanner sc = new Scanner(System.in);
int n , i , sum;
System.out.println("Enter input number");
n = sc.nextInt();
sum = 0;
for (i = 1 ; i < n ; i++){
if (n % i == 0){
sum = sum + i;
}
}
if (sum > n){
System.out.println(n + " is an abundant number");
}
else{
System.out.println(n + " is not an abundant number");
}
}
}

int choice,n,d,i,a,b,c;
System.out.println("Select the number for your desired option...!");
System.out.println(" ");
System.out.println("1.) Generate the Tribonacci series up to n terms");
System.out.println("2.) Print the series: 0, 6, 24, 60 up to n terms");
System.out.println("3.) Exit");
choice = sc.nextInt();
switch (choice){
case 1:
System.out.println("Enter the number of terms you want to
generate");
n = sc.nextInt();
a = 0;
b = 1;
c = 1;
if (n==1){
System.out.println("Tribonacci series: " + a);
break;
}
if (n==2){
System.out.println("Tribonacci series: " + a + ", " + b);
break;
}
System.out.print("Tribonacci series: " + a + ", " + b + ", " + c);
for (i = 3; i < n; i++) {
d = a + b + c;
System.out.print(", "+ d);
a = b;
b = c;
c = d;
}
System.out.println();
break;
case 2:
System.out.println("Enter the number of terms you want to
generate");
n = sc.nextInt();
System.out.print("Series: ");
for (i = 1; i <= n; i++) {
int term = (i * i * i) - i;
if (n == i){
System.out.print(term);
}
else{
System.out.print(term + ", ");

import java.util.*;
class program3{
public static void main(){
Scanner sc = new Scanner(System.in);
int max ,min ,num ,i;
min = 0;
max = 0;
System.out.println("Enter 15 numbers:");
for (i = 1; i <= 15; i++) {
num = sc.nextInt();
if (i == 1){
max = num;
min = num;
}
if (num > max){
max = num;
}
if (num < min){
min = num;
}

You might also like