Print 'Censored if userinput contains the word"darn', else print userinput End with newline. Ex: if userinput is "That darn cat.:. then output is: Censored
Ex: If userinput is Dang, that was scaryl", then output is: Dang, that was scary
Note: If the submitted code has an out-of-range access, the system will stop running the code after a few seconds, and report Program end never reached The system doesn't print the test case that caused the reported message.
import java.util.Scanner;
public class Censoredwords {
public static void main (String [] args) { Scanner scnr = new Scanner(System.in); String userInput; userInput = scnr.nextline);
}}
Please find the code below::
CensoredWords.java
package classes1;
import java.util.Scanner;
public class CensoredWords {
public static void main(String[] args) {
Scanner scnr = new
Scanner(System.in);
String userInput;
userInput =
scnr.nextLine();
if(userInput.contains("darn")){
System.out.println("Censored");
}else{
System.out.println(userInput);
}
}
}
output:
Print 'Censored if userinput contains the word"darn', else print userinput End with newline. Ex iIf userinput...
WRITE THIS IN JAVA!!!! Print "Censored" if userlnput contains the word "darn", else print userlnput. End with newline. Ex: If userlnput is "That darn cat.", then output is: Censored Ex: If userlnput is "Dang, that was scary!", then output is: Dang, that was scary! Note: If the submitted code has an out-of-range access, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the...
Unreachable statement??????? CSIT 111 home> 313: More string operations E zyBooks catalog Print 'Censored if userinput contains the word 'darn, else print userinput. End with newline Note: These activities may test code with different test values. This activity will perform three tests, with userinput of That darn cat', then with Dang, that was scary!", then with I'm darning your socks.. See How to Use zyBooks . Also note: If the submitted code has an out-of-range access, the system will stop...
Write three statements to print the first three elements of array runTimes. Follow each statement with a newline. Ex: If runTime = {800, 775, 790, 805, 808}, print: 800 775 790 Note: These activities will test the code with different test values. This activity will perform two tests, both with a 5-element array. See "How to Use zyBooks". Also note: If the submitted code tries to access an invalid array element, such as runTimes[9] for a 5-element array, the test...
7.2.3: Printing array elements with a for loop. Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10}, print: 7 9 11 10 10 11 9 7 Hint: Use two for loops. Second loop starts with i = courseGrades.length - 1. (Notes) Also note: If the submitted code tries to access an invalid...
in java Feedback? CHALLENGE ACTIVITY 5.2.2: Printing array elements. Write three statements to print the first three elements of array run Times. Follow each statement with a newline. Ex: If runTime = (800,775, 790, 805, 808) print: 800 775 790 Note: These activities will test the code with different test values. This activity will perform two tests, both with a 5 element array. See 'How to Use zyBooks". Also note: If the submitted code tries to access an invalid array...
CHALLENGE ACTIVITY 3.11.1: Using boolean. D Assign is Teenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign is Teenager with false. 1 import java.util.Scanner; 3 public class TeenagerDetector 1 public static void main (String [] args) { Scanner scnr = new Scanner(System.in); boolean isTeenager; int kidAge; D}]oll kidage = scnr.nextInt(); /* Your solution goes here */ Go USB if (isTeenager) { System.out.println("Teen"); else { System.out.println("Not teen"); 20 Run Feedback? CHALLENGE ACTIVITY 3.11.2: Boolean in branching statements. Write...
Write a do-while loop that continues to prompt a user to enter a number less than 100, until the entered number is actually less than 100. End each prompt with newline Ex: For the user input 123, 395, 25, the expected output is: Enter a number (<100): Enter a number (<100): Enter a number (<100): Your number < 100 is: 25 import java.util.Scanner; public class NumberPrompt { public static void main (String [] args) { Scanner scnr = new Scanner(System.in);...
Answer in JAVA 1. Complete the method definition to output the hours given minutes. Output for sample program: 3.5 import java.util.Scanner; public class HourToMinConv { public static void outputMinutesAsHours(double origMinutes) { /* Your solution goes here */ } public static void main (String [] args) { Scanner scnr = new Scanner(System.in); double minutes; minutes = scnr.nextDouble(); outputMinutesAsHours(minutes); // Will be run with 210.0, 3600.0, and 0.0. System.out.println(""); } } 2....
Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp = {90, 92, 94, 95}, print: 90, 92, 94, 95 Your code's output should end with the last element, without a subsequent comma, space, or newline. import java.util.Scanner; public class PrintWithComma { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); final int NUM_VALS = 4; int[] hourlyTemp = new...
In JAVA ACTIVITY 3.10.1: Rock-paper-scissors. Write a switch statement that checks nextChoice. If o print "Rock". If 1 print "Paper". If 2 print "Scissors'. For any other value, print "Unknown'. End with newline. 2. 4 1 import java.util.Scanner; 3 public class Roshambo public static void main(String [] args) { 5 Scanner scnr - new Scanner(System.in); 6 int nextChoice; 7 8 nextChoice - scnr.nextInt(); 9 10 /" Your solution goes here */ 11 12 13} CHALLENGE ACTIVITY 3.10.2: Switch statement to...