0% found this document useful (0 votes)
10 views3 pages

Java Training Feb

Uploaded by

Harini
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)
10 views3 pages

Java Training Feb

Uploaded by

Harini
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/ 3

JAVA TRAINING FEB

05/02/2023

import java.util.*;

class GoodMorning{

public static void main(String[] args) {


Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

for(int i = 1; i <= n ; i++){

if(i%5 == 0 && i%3 == 0){


System.out.println("Good Morning");
}

else if(i%5 == 0){


System.out.println("Morning");
}

else if(i%3 == 0){


System.out.println("Good");
}
else{
System.out.println(i);
}

}
}

---------------------------

import java.util.*;
import java.util.Arrays;

class ArraysRotate{

public static void main(String[] args) {


Scanner sc = new Scanner(System.in);

int arr[] = {1,2,3,4,5};

int n = sc.nextInt();

for(int i = 0; i < n ; i++){

int temp = arr[arr.length-1];

for(int j = arr.length-1 ; j > 0 ; j--){


arr[j]= arr[j-1];

}
arr[0] =temp;

for(int i = 0 ; i < arr.length ; i++){


System.out.print(arr[i]+" ");
}

}
}

// 3
// 3 4 5 1 2

// for(int i = 0; i < n ; i++){

// int temp = arr[0];

// for(int j = 0 ; j < arr.length-1 ; j++){


// arr[j]= arr[j+1];

// }
// arr[arr.length-1] =temp;

// }

// for(int i = 0 ; i < arr.length ; i++){


// System.out.print(arr[i]+" ");
// }

// }
// }

// 3
// 4 5 1 2 3

---------------

import java.util.*;
import java.io.*;

class RightTriangle {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();

for (int i = 0; i < n ; i++ , System.out.println()){


for ( int j = 0 ; j <= i ; j++){
System.out.print("*");
}

}
}
}
5
*
**
***
****
*****

------------------
Home work

get the number , count the iterations that the number's square

import java.util.Scanner;

public class SquareCount {

public static void main(String[] args) {


Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

int count = 0 , x = 0 ;

while(n > 0) {
for(int i = 1 ; i < n ; i++){
int s = i * i ;
if( s < n){
x = s ;

}
}
n = n - x;
count++;

}
System.out.println(count);
}

-----------------------------------------------------

06/02/2024

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy