Concept explainers
Holy digits Batman! The Riddler is planning his next caper somewhere on Pennsylvania Avenue. In his usual sporting fashion, he has left the address in the form of a puzzle. The address on Pennsylvania is a four-digit number where:
- All four digits are different
- The digit in the thousands place is three times the digit in the tens place
- The number is odd
- The sum of the digits is 27
Write a
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Problem Solving with C++, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (9th Edition)
Additional Engineering Textbook Solutions
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Starting Out With Visual Basic (8th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
- eeringQ&A LibraryCreate a java program 1. Broken Record Looping strings works like playing a broken record – it repeats something over and over again. But what's great about loops is that we can define as to how many times it will repeat something with proper code, and that's what we're about to do now using while() loops. Instructions Scan a positive integer and store it in a variable. Using while() loop, repeatedly print out "CodeChum is awesome" for the same number of times as that of the inputted integer. Each outputted string must be separated in new lines. Don't forget to make an increment variable that will increase its value per iteration so as to not encounter a forever loop and have errors, okay? Input Format A line containing an integer. Input Sample 4 Output Format Multiple lines containing a string. Output Sample CodeChum·is·awesome CodeChum·is·awesome CodeChum·is·awesome CodeChum·is·awesome Create a java program 1. Broken Record Looping strings works like playing…arrow_forwardAll the loops below are meant to do the same thing, except... Select one: a. int index = 0; do{ if(numbers[index]%2 == 1) System.out.println(numbers[index]+" is an odd number."); index++;}while(index < numbers.length); b. for(int a=0 ;a < numbers.length; a +=2){ System.out.println(numbers[a]+" is an odd number.") } c. for(int num:numbers){ if(num%2 == 1) System.out.println(num+" is an odd number.") } d. int index = 0; while(index < numbers.length){ if(numbers[index]%2 == 1) System.out.println(numbers[index]+" is an odd number."); index++; } CLEAR MY CHOICEarrow_forwardJAVA Prime numbers are numbers that have only 2 factors: 1 and themselves. For example, the first 5 prime numbers are 2, 3, 5, 7, and 11. Write a Java program that takes integer inputs N (where N >= 2 ) from the user until the user input is 0 (zero is the sentinel value) and check if the user input value is a prime number or not. Use nested loops. Sample Input and output: Enter a number > 2 Output: prime Enter a number > 11 Output: prime Enter a number > 10 Output: not prime Enter a number > 9 Output: not prime Enter a number > 23 Output: prime Enter a number > 0 Output: Loop ends. Good Bye!arrow_forward
- JAVA CODE PLS THANK YOU 4. A Shorter Three by CodeChum Admin Numbers in threes are awesome! But the one last time was too lengthy to look at, so I just want to view it in a shorter but still readable format. You okay with this task? Instructions: Print out all numbers from 1 to 100 that is divisible by 3 using a for loop just like the last problem, but this time, with each number only separated by the space like that of the sample output. Output A line containing integers divisible by 3 separated by a space. 3·6·9·12·15·18·21·24...arrow_forwardJAVA LANGUAGE PLS THANK YOU 1. Squares by CodeChum Admin Looping random numbers and manipulating those values are fun, too! Why don't we try one that returns the square of an inputted number repeatedly until the user inputs 0? Let's do this! Instructions: Using a do...while() loop, continuously scan for random integers that will be inputted by the user and print out its square, separated in each line. Once the inputted value is 0, it will still print out its square value but should then terminate the loop afterwards. Use this concept in making your loop condition. Input Multiple lines containing an integer. 2 6 0 Output Multiple lines containing an integer. 4 36 0arrow_forwardUse nested loop in Java language. This program asks the user to enter an integer from 3 to 9* and prints a pattern of numbers based on that number.* For example, given the number 4 as input, the output would be:* * 1** 21** 321** 4321** 321** 21** 1** * Print a newline between the prompt and the beginning of the stars.* Note that no input validation is required.arrow_forward
- JAVA Program modify this program below: so it does not use a while loop. Instead it uses recursive method that doesn't copy the string over and over again. import java.util.Scanner;public class PalindromeChecker { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (true) { System.out.print("Please enter a string to test for palindrome or type QUIT to exit:\n"); String input = scanner.nextLine().toLowerCase(); if (input.equals("quit")) { break; } if (isPalindrome(input)) { System.out.println("The input is a palindrome."); } else { System.out.println("The input is not a palindrome."); } } } private static boolean isPalindrome(String str) { str = str.replaceAll("[^a-zA-Z0-9]", ""); int left = 0; int right = str.length() - 1; while (left < right) { if…arrow_forwardInstructions Complete the lab using “for loop”. Do not write the code in multiple programs. All the 3 methods should be written in 1 program. Write a java program calls the following methods: printStars(): Takes an int (n) as parameter and prints n stars (*) using for loop. Multiples(): Takes an int (n) as parameter and prints first 10 multiples n in a single line using for loop. hasAnEvenDigit: Takes an int (n) as parameter and returns whether n has at least one digit whose value is even. Return true if the number has at least one even digit else false if none of the digits are even. For example, the call hasAnEvenDigit(33267) should return true and hasAnEvenDigit(7591) should return false. [Hint: n%10 returns the last digit and n/10 returns everything except the last digit]arrow_forwardIn Java A while loop reads integers from input. Write an expression that executes the while loop until a positive integer is read from input. Ex: If the input is -20 -43 -25 -22 15, then the output is:User entered -20User entered -43User entered -25User entered -22Loop terminated while () {arrow_forward
- Create a program in Java called CountDown. Print “This is a countdown!” in quotation marks. Use a for loop to count down from 25. Print the numbers. Print “Blast Off!” in quotation marks once count down ends.arrow_forward/** USING WHILE LOOPS ONLY + public class while loops * Given two integers, the second larger than the first, this program:* 1) prints the even numbers between the first and second number inclusive* 2) prints the sum of those even numbers* 3) prints the odd numbers between the first and second number inclusive* 4) prints the sum of those odd numbers* * Example:* Enter an integer: 10* Enter one larger than the first: 20* Even numbers: 10 12 14 16 18 20* Sum of even numbers = 90* Odd numbers: 11 13 15 17 19* Sum of odd numbers = 75**the image below also states the requirements**arrow_forward1. Write a an algorithm that asks the user to input a positive integer n and counts how many of the squares of the integers from 1 to n end in a 1.2. Write a an algorithm that asks the user to input a positive integer n and counts how many of the squares of the integers from 1 to n end in a 4 and how many end in a 9.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT