Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SmallLarge {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- double highestValue = in.nextDouble();
- double lowestValue = in.nextDouble();
- int tries = 0;
- for (int currenttries = 0; currenttries <= 2; currenttries++)
- {
- double nextValue = in.nextDouble();
- if (nextValue > highestValue)
- {
- highestValue = nextValue;
- tries = currenttries;
- }
- double newValue = in.nextDouble();
- if (newValue < lowestValue)
- {
- newValue = lowestValue;
- tries = currenttries;
- }
- }
- System.out.println("Biggest: " + highestValue);
- System.out.println("Smallest: " + lowestValue);
- }
- }
- ----------------------------------------------------------------------------------------------------------------------------------
- package evenodd;
- import java.util.Scanner;
- public class EvenOdd {
- public static void main(String[] args)
- {
- Scanner in = new Scanner(System.in);
- Scanner n = new Scanner(System.in);
- System.out.print("How many numbers do you want to enter?");
- int numEnter = n.nextInt();
- int numOdd = 0;
- int numEven = 0;
- for (int input = 1; input <= numEnter; input++)
- {
- int even = in.nextInt();
- if (even %2 == 0)
- {
- numEven++;
- }
- else
- {
- numOdd++;
- }
- }
- int theOdd = numOdd;
- int theEven = numEven;
- System.out.println("odds " + theOdd);
- System.out.print("evens " + theEven);
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------
- public class PowersOfTwo {
- public static void main(String[] args) {
- int power = 0;
- int i = 2;
- while (power < 20)
- {
- int n = power * power;
- int j = n * i;
- power++;
- System.out.println(j);
- }
- }
- }
- ---------------------------------------------------------------------------------------------------------------------------------
- package adjacent;
- import java.util.Scanner;
- public class Adjacent {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- boolean found = false;
- int position = 0;
- char numCh;
- int numMinus;
- System.out.println("Enter some numbers");
- int input = in.nextInt();
- String s = Integer.toString(input);
- while(!found && position < s.length())
- {
- numCh = s.charAt(position);
- if (numCh %2 != 0 )
- {
- found = true;
- System.out.print(numCh);
- continue;
- }
- else
- {
- position++;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement