Java_beginner(Repl.it)/Auto-Graded-Course(AP CS A)

    038 - Method Header Practice 3

    038 - Method Header Practice 3

    Write a method header on line two with the following specs: Returns: a String Name: makeCapital Parameters: a String named "name" You should not be writing code on any line other than #2 Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import java.util.*; class Main { public static String makeCapital(String name){ return name.toUpperCase(); } //test case below (dont change): public static void Bakjoon(..

    036 - Method Header Practice 1,2

    036 - Method Header Practice 1,2

    036 - Method Header Practice 1 Write a method header on line two with the following specs: Returns: an integer Name: practiceOne Parameters: none You should not be writing code on any line other than #2 Solution 1 2 3 4 5 6 7 8 9 10 11 12 import java.util.*; public class Main { public int practiceOne(){ { return 2; } } } 037 - Method Header Practice 2 Write a method header on line two with the f..

    035 - Sum Odds in Range

    035 - Sum Odds in Range

    You are given two inputs: int num1; int num2; You can assume that the following: num2 > num1 ==> TRUE You are to write a program that will calculate and print out the SUM OF ODD numbers in between num1 and num2 inclusive. Your output should all be on one line, separated by spaces. Sample input/output: #1: 3 #2: 11 Output: 35 #1: 4 #2: 20 Output: 96 #1: -2 #2: 6 Output: 8 Solution 1 2 3 4 5 6 7 8..

    034 - Big Number Program (From Decoding)

    034 - Big Number Program (From Decoding)

    You are given two inputs: int num1; int num2; You can assume that the following: num2 > num1 ==> TRUE You are to write a program that will print out all the ODD numbers in between num1 and num2 inclusive. Your output should all be on one line, separated by spaces. Sample input/output: #1: 3 #2: 11 3 5 7 9 11 #1: 4 #2: 20 5 7 9 11 13 15 17 19 #1: -2 #2: 6 -1 1 3 5 Solution 1 2 3 4 5 6 7 8 9 10 11..

    033 - For Loop Challenge 2 (optional)

    033 - For Loop Challenge 2 (optional)

    Write code that will take in a String input and check to see if it is a palindrome or not. A palindrome means that the characters are the same forwards and backwards, ignoring spaces. Examples of palindromes: racecar was it a car or a cat I saw never odd or even rats live on no evil star Your check should be case insensitive too. For example, "Bob" is a palindrome, despite the first B being capi..

    032 - For Loop Challenge 1 (optional)

    032 - For Loop Challenge 1 (optional)

    The fibonacci sequence is a sequence of numbers in which the next number is the sum of the previous two numbers. The first two numbers of the fibonacci sequence are 0, 1. The first 8 numbers of the fibonacci sequence are 0, 1, 1, 2, 3, 5, 8, 13 Write some code to print out the first X numbers of the fibonacci sequence. Your output should be on one line, with each number separated by a space. You..

    031 - Further For Loop Practice 7 (mIxEd CaSe)

    031 - Further For Loop Practice 7 (mIxEd CaSe)

    Given the following inputs: String s; Write a for loop that will print out the string in alternating cases, with the first letter being lowercase. Keep in mind the following String methods: str.toUpperCase(); //make it uppercase str.toLowerCase(); //make it lowercase DO NOT USE .charAt()! .charAt returns a character, and you need a string in order to make it upper/lowercase. To get a letter at a..

    030 - Further For Loop Practice 6 (reverse string)

    030 - Further For Loop Practice 6 (reverse string)

    Given the following inputs: String s; Write a for loop that will print out the reverse of the string. Sample input/outputs: In: manhattan out: nattahnam In: processor out: rossecorp In: racecar out: racecar Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import java.util.Scanner; class Bakjoon { public static void main(String[] args) { Scanner inp = new Scanner(System.in); System.out.print("In:"); Str..

    029 - Further For Loop Practice 5 (printing characters)

    029 - Further For Loop Practice 5 (printing characters)

    Given the following inputs: String s; Write a for loop that will print out each letter of the string s, separated by spaces, on the same line. Sample input/outputs: In: hello out: h e l l o In: covert out: c o v e r t In: blasphemy out: b l a s p h e m y Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import java.util.Scanner; class Bakjoon { public static void main(String[] args) { Scanner inp = new ..

    028 - Further For Loop Practice 4 (repeating X times)

    028 - Further For Loop Practice 4 (repeating X times)

    Given the following inputs: int x; Write a for loop that will print out "AP CS A" x number of times, new line per print. Sample input/outputs: In: 3 AP CS A AP CS A AP CS A In: 5 AP CS A AP CS A AP CS A AP CS A AP CS A In: 1 AP CS A Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import java.util.Scanner; class Bakjoon { public static void main(String[] args) { Scanner inp = new Scanner(System.in); Sy..

    027 - Further For Loop Practice 3 (descending)

    027 - Further For Loop Practice 3 (descending)

    Given the following inputs: int x; Write a for loop that will print out a series of numbers starting at one less than x and ending at 0. Sample input/outputs: In: 7 out: 6 5 4 3 2 1 0 In: 12 out: 11 10 9 8 7 6 5 4 3 2 1 0 In: 20 out:19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 import java.util.Scanner; class Main { public static void main(String[] a..

    026 - Further For Loop Practice 2 (skipping by 3s)

    026 - Further For Loop Practice 2 (skipping by 3s)

    Given the following inputs: int x; Write a for loop that will print out a series of numbers starting at 0 and ending before x, skipping 3 each time (excluding x). Sample input/outputs: In: 7 out: 0 3 6 In: 12 out: 0 3 6 9 In: 20 out: 0 3 6 9 12 15 18 HINT: You'll want to change the increment part of the for loop! 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import java.util.*; class Bakjoon { public stat..

    025 - Further For Loop Practice 1 (ascending)

    025 - Further For Loop Practice 1 (ascending)

    Given the following inputs: int x; Write a for loop that will print out a series of numbers starting at 0 and ending at the x, exclusive. Sample input/outputs: In: 3 out: 0 1 2 In: 8 out: 0 1 2 3 4 5 6 7 In: 5 out: 0 1 2 3 4 Solution 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 import java.util.*; class Main { public static void main(String[] args) { Scanner inp = new Scanner(System.in); System.out.print..

    024 - For Loop 6 (optional)

    024 - For Loop 6 (optional)

    Using a for loop, determine whether the integer variable max is prime or not. If the number is prime, print out "prime". If it's not, print out "not prime". Keep in mind that 1 is NOT a prime number. You can use the following to find the square root of a number (you may or may not use this): Math.sqrt(num) Sample input/outputs: In: 100 out: not prime In: 17 out: prime In: 9 out: not prime In: 1 ..

    023 - For Loops 5

    023 - For Loops 5

    Write a for loop that will loop through every letter of the input and print out just the vowels. Sample input/outputs In: howdyho out:oo In: huehuehuehue out:ueueueue In: poopoo what idk what im doing out:ooooaiaioi 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import java.util.Scanner; class Main { public static void main(String[] args) { Scanner inp = new Scanner(System.in); System.out.print..

    022 - For Loops 4

    022 - For Loops 4

    Write a for loop that will print out every other letter in a String, starting with the first letter. These letters should be printed all on one line with no space in between. Sample input/outputs In: hello out:hlo In: so code very wow out:s oevr o 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import java.util.Scanner; class Main { public static void main(String[] args) { Scanner inp = new Scan..

    021 - For Loops 3

    021 - For Loops 3

    Write a for loop that will loop through every character of a word and print out each character, each on a separate line Sample inputs/outputs: In: hello h e l l o 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 import java.util.Scanner; class Main { public static void main(String[] args) { Scanner inp = new Scanner(System.in); System.out.print("In:"); String word = inp.nextLine(); //write your code below..

    020 - For Loops 2

    020 - For Loops 2

    Write a for loop that will print out the numbers starting at 1 and ending at twice the end number exclusive. Each number should be on the same line, separated by a space. Sample inputs/outputs: In: 5 0 1 2 3 4 5 6 7 8 9 In: 10 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 In: -5 (no output) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import java.util.Scanner; class Main { public static void..

    019 - For Loops 1

    019 - For Loops 1

    Inputs: int end; Write a for loop that will print out the numbers starting at 1 and ending at the input inclusive. The numbers printed should all be on the same line separated by a space. Sample inputs/outputs: In: 5 1 2 3 4 5 In: 10 1 2 3 4 5 6 7 8 9 10 In: -5 (no output) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 import java.util.Scanner; class Main { public static void main(String[] args) {..

    018 - Conditional Statement Practice 4

    018 - Conditional Statement Practice 4

    For you to do: Given a string variable "word", do the following tests If the word ends in "y", print "-ies" If the word ends in "ey", print "-eys" If the word ends in "ife", print "-ives" If none of the above is true, print "-s" No more than one should be printed. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 import java.util.*; class Main { public static void ..