Write an if-else statement that prints "Goodbye" if userString is "Quit", else prints "Hello". End with newline. 1 import java.util.Scanner; 2 3 public class DetectWord { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); String userString; 4 5 7 8. userString scnr.next(); 9 10 /* Your solution goes here 11 12 } 13 }
Q: Assign isTeenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign isTeenager with…
A: import java.util.*; public class TeenagerDetector {public static void main (String [] args) {Scanner…
Q: Write an if-else statement for the following: If userTickets is less than 5, execute awardPoints =…
A: import java.util.*;public class Main{ public static void main(String[] args) {…
Q: Write an expression that prints "Eligible" if userAge is between 18 and 25 inclusive. Ex 17 prints…
A: Solution: The expression that prints Eligible if the user age is between 18 and 25 inclusive can be…
Q: plain this java code
A: Descriptions: 1- Please check the following updated code with comments line by line. 2- There are…
Q: CHALLENGE ACTIVITY 422784.2543518.qx3zqy? Jump to level 1 Write an if-else statement for the…
A: If user Tickets is less than 8, execute award Points = 1. Else, execute award Points = User Tickets.
Q: QUESTION: Why I can't run this coding? . import java.util.*; public class Children { String…
A: import java.util.*;public class Children{ String name; int friends; public Children(String…
Q: Step 1) Copy the following code into an Editor public class Test{ public static void main(String a…
A: The step-by-step complete code is given below, with proper explanations.
Q: public class DebugThree2 { public static void main(String args[]) int a = 2, b = 5, c = 10; add(a,…
A: Many syntax and logical errors may disturb our program and prevent us from achieving our output.…
Q: Write a pesudocode for the following code: public class EOM1 { public static void main(String[]…
A: The above java code is indicating a transaction between customer and the salesman. The customer buys…
Q: Consider the following piece of code: public static void main(String[] args) { BankAccount…
A: Below are the answers:
Q: Define the missing method. Use "this" to distinguish the local member from the parameter name. //…
A: Program code: File name: CablePlan.java //define a class CablePlan public class CablePlan {…
Q: CHALLENGE ACTIVITY 422784.2543518.qx3zq7 Jump to level 1 Write an if-else statement for the…
A: The answer for the above question is given in the below steps.
Q: Can you indentify Error in this code and repair it .The output of days is not coming correct.…
A: Updated Code import java.util.Scanner;//Data.javapublic class Date { Scanner sc=new…
Q: Write an if-else statement with multiple branches. If givenYear is 2101 or greater, print "Distant…
A: The below given java program will obey the following rubrics: Importing essential header files.…
Q: public class output{ public static int check (int a, int b, int c) { if(a==0) return (b); else if…
A: Given:
Q: Write an expression that prints "Special number" if specialNum is -99, 0, or 44.…
A: Given: To write the expression within the if statement so that the code gives correct output. The…
Q: Find the output statement that is used for debugging the following code:
A: Find the answer with reason given as below :
Q: public class MysteryReturn 2 { 3 public static void main(String[] args) 4 { 5 int x = 1; 6 int y =…
A: Please find the answer below :
Q: Write an if-else statement for the following: If userTickets is less than 6, execute award Points =…
A: Your given program is logically correct but the issue is in the closing of blocks. Blocks were…
Q: Using a conditional expression, write a statement that increments numUsers if updateDirection is 1,…
A: As the whole program is already designed We will use the conditional statement i.e (if else) to…
Q: Write a switch statement that checks nextChoice. If 0, print "Rock". If 1, print "Paper". If 2,…
A: // Import the required the packageimport java.util.Scanner; public class Main{ public static void…
Q: CHALLENGE 2.1.3: Basic if-else. ACTIVITY 422784.2543518.qx3zqy7 Jump to level 1 Write an if-else…
A: The code implementation in Java is given below. Algorithm: Begin. Prompt the user to input the…
Q: n Java trace the table for a while loop public class Main { public static void main(String[] args)…
A: According to the Question below the Solution:
Q: import java.util.Scanner; public class BillAmount // To calculate the total bill amount after the…
A: 1) Code in question is Java program to read the bill amount from user, calculate the discount based…
Q: Write multiple if statements: If carYear is before 1967, print "Probably has few safety features."…
A: According to the information given:- We have to follow the instruction mentioned in order to get…
Q: Analyze the following code: public class Test { public static void main(String[] args) { Bb = new…
A: Hello Student Greeting Hope you are doing great. I will try my best to answer your question. Thank…
Q: * Constructor for objects of class SimpleBankAccount public SimpleBankAccount (){ balance- 0.0; ac…
A: Given that:
Q: Fill with appropriate java keywords/syntaxes in the following method overloading program. package…
A: The modified code the output has been given in step 2.
Q: public class JavaApplication7 { public static void main(String [] args) { //TODO - write your own…
A: public class Main{ public static void main(String[] args) { //testing method…
Q: 1 package package1; 2 3 public class Operation { 40 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22…
A: As per guidelines we are supposed to answer only one question. Kindly repost other questions a…
Q: Write a statement that increases numPeople by 5. Ex: If numPeople is initially 10, the output is:…
A: The answer is given below.
Q: import java.util.Scanner; public class MorgansBonuses { public static void main(String[] args)…
A: import java.util.Scanner; public class MorgansBonuses { public static void main(String[] args) {…
Q: Write a second constructor as indicated. Sample output: User1: Minutes: 0, Messages: 0 User2:…
A: Program //PhonePlan.java public class PhonePlan { private int freeMinutes; private int…
Q: Can you help debug my program? It's in Java. Attached: my code screenshot. Problems: 1) next cannot…
A: The modified code is indicated in bold. import java.util.Scanner; public class bounds {…
Q: CHALLENGE ACTIVITY 422784.2543518.qx3zqy7 Jump to level 1 Write an if-else statement for the…
A: #include <iostream>using namespace std; int main(){ int awardPoints; int userTickets;…
Q: import java.at."; import javax. swing."; public class RectangleMonday etends JFrame{ public…
A: Introduction of Program: The java program uses the concept of JFrame and it provides a window on the…
Q: import javax.swing.JOptionPane; public class DebugTwo4 { // start main method public static void…
A: import javax.swing.JOptionPane; public class DebugTwo4 { // start main method public static void…
Q: 1. public class Foo { 2. public static void main (String[] args) { 3. int i=1: 4. int j =i++; 5. if…
A: d) 5
Q: Java-OOP write the dry run of the following program public abstract class Payment { protected double…
A: According to the information given:- we have to compile and dry run the given code in Java.
Q: Write the printItem() method for the base class. in Java Sample output for below program: Last…
A: // ===== Code from file ItemInventory.java =====import java.util.ArrayList; public class…
Q: Write an if-else statement for the following: If userTickets is greater than 8, execute awardPoints…
A: Hey, thank you for your question. To solve this problem, we can add a small coding snippet of…
Q: Write multiple if statements: If carYear is before 1967, print "Probably has few safety features."…
A: 1. Taking User input for the carYear variable. 2. Writing multiple if statements as per given…
Q: Read the following code and select the correct output. Linel: public class Foo { public void…
A: Please give positive ratings for my efforts. Thanks. ANSWER Here, according to the given…
Q: Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E"…
A: Answer:
Q: CHALLENGE 2.1.3: Basic if-else. ACTIVITY 4227842543518.37 Jump to level 1 Write an if-else statement…
A: The answer is given below. Algorithm: Input value of userTickets. If userTickets less than 8 print…
Q: Write a switch statement that checks origLetter. If 'a' or 'A', print "Alpha". If 'b' or 'B', print…
A: // Import the required the packageimport java.util.Scanner; public class ConvertToGreek{ public…
Q: Assign isTeenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign isTeenager with…
A: // Import the required packageimport java.util.Scanner; public class TeenagerDetector{ public static…
Q: package lab06;;public class gradereport { public static void main(String[] args) {…
A: After correcting the code, I have provided JAVA CODE along with CODE SCREENSHOT and OUTPUT…
Q: Hello! Can you help debug my Java program? I'm writing a program to convert Celsius to Farenheit.…
A: Program: //import the header file import java.util.Scanner; //definition of class public…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
- Complete method printPopcornTime(), with int parameter bagOunces, and void return type. If bagOunces is less than 2, print "Too small". If greater than 10, print "Too large". Otherwise, compute and print 6 * bagOunces followed by " seconds". End with a newline. Example output for ounces = 7: 42 seconds import java.util.Scanner; public class PopcornTimer {public static void printPopcornTime(int bagOunces) { /* Your solution goes here */ } public static void main (String [] args) {Scanner scnr = new Scanner(System.in);int userOunces; userOunces = scnr.nextInt();printPopcornTime(userOunces);}}Find the output statement that is used for debugging the following code: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx import java.util.Scanner;public class GuessMyAge {public static void myGuess(int low, int high, Scanner scnr, String indent) {int mid; char userAnswer; mid = (low + high) / 2;System.out.print("Is it " + mid + "? (</>/=): ");userAnswer = scnr.next().charAt(0);if ((userAnswer != '<') && (userAnswer != '>')) { System.out.println("Great!");}else {if (userAnswer == '<') {System.out.println(indent + "User is younger.");myGuess(low, mid, scnr, indent + " ");}else {myGuess(mid + 1, high, scnr, indent + " ");}}}public static void main(String[] args) {Scanner scnr = new Scanner(System.in);System.out.println("Finding your age!");myGuess(0, 100, scnr, " "); }}Complete the second printSalutation() method to print the following given personName "Holly" and customSalutation "Welcome": Welcome, Holly End with a newline. import java.util.Scanner; public class MultipleSalutations {public static void printSalutation(String personName) {System.out.println("Hello, " + personName);} //Define void printSalutation(String personName, String customSalutation)... /* Your solution goes here */ public static void main (String [] args) {printSalutation("Holly", "Welcome");printSalutation("Sanjiv");}}
- import java.util.Scanner; public class sample { public static double totalProfit = 0.00; public static double totalTax = 0.00; static void ProfitandTax(double S , double E , int count){ double Tax = (S * 30.00)/100.00; /* Tax is 30% of sales and it is also considered as expenses of business so this will be a type of expenses */ double totalExpense = (E + Tax ); double Profit = (S - totalExpense); // Profit is given by sales subtracted by expenses System.out.println("Profit for " + count + " branch is : " + Profit); System.out.println("Tax for " + count + " branch is : " + Tax); totalProfit += Profit; totalTax += Tax; } public static void main(String[] args){ Scanner sc = new Scanner(http://System.in); System.out.println("Enter no of branches you have "); int k = sc.nextInt(); for(int i=0;i< k ;i++){ System.out.println("Enter Sales for " + (i+1 )+ " branch " ); double S = sc.nextDouble(); System.out.println("Enter Expenses for " + (i+1) + " branch " ); double E = sc.nextDouble();…Answer with a given JAVA question below. Consider the following code: public class Quiz{ public String name; public double totalPoints; public String getName() { return this.name; } public double getTotalPoints() { return this.totalPoints; } } Based on the Java code, explain where information hiding is being violated, why it is considered a violation, and how a programmer should fix the violation.Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. End with a newline. Ex: printFeetInchShort(5, 8) prints: 5' 8" Hint: Use \" to print a double quote. import java.util.Scanner; public class HeightPrinter { /* Your solution goes here */ public static void main (String [] args) { Scanner scnr = new Scanner(System.in); int userFeet; int userInches; userFeet = scnr.nextInt(); userInches = scnr.nextInt(); printFeetInchShort(userFeet, userInches); // Will be run with (5, 8), then (4, 11)}}
- Complete the method definition to return the hours given minutes. Output for sample program:3.5 -java code- import java.util.Scanner;public class HourToMinConv { public static double getMinutesAsHours(double origMinutes) { /* Your solution goes here */ } public static void main (String [] args) { Scanner scnr = new Scanner(System.in); double minutes; minutes = scnr.nextDouble(); // Will be run with 210.0, 3600.0, and 0.0. System.out.println(getMinutesAsHours(minutes)); }}Q27 for java programing: public static void main(String[] args) { Dog[] dogs = { new Dog(), new Dog()}; for(int i = 0 ; i < dogs.length; i++) dogs[i].wo(); Cat[] cats = { new Cat(),new Cat(),new Cat()}; for(int i = 0 ; i < cats.length; i++) cats[i].me(); System.out.print(Dog.getCount()+" woofs and"); System.out.println(Cat.getCount()+" mews"); System.out.println("=====>>>"+decision()); } class Counter { private static int count; public static void inc() { count++;} public static int getCount() {return count;} } class Dog extends Counter{ public Dog(){} public void wo(){inc();} } class Cat extends Counter{ public Cat(){} public void me( ){inc();} } The Correct answer: public static void main(String[] args) { Dog[] dogs = { new Dog(), new Dog()}; for(int i = 0 ; i < dogs.length; i++) dogs[i].wo(); Cat[] cats = { new…01 answer this Complete method printPopcornTime(), with int parameter bagOunces, and void return type. If bagOunces is less than 2, print "Too small". If greater than 10, print "Too large". Otherwise, compute and print 6 * bagOunces followed by " seconds". End with a newline. Example output for ounces = 7: 42 seconds import java.util.Scanner; public class PopcornTimer {public static void printPopcornTime(int bagOunces) { /* Your solution goes here */ } public static void main (String [] args) {Scanner scnr = new Scanner(System.in);int userOunces; userOunces = scnr.nextInt();printPopcornTime(userOunces);}}}
- Java Program Fix this Rock, Paper and scissor program so I can upload it to Hypergrade and it can pass all the test cases. Here is the program: import java.util.Random;import java.util.Scanner;public class RockPaperScissors { public static void main(String[] args) { if (args.length != 1) { System.out.println("Please provide a seed as a command line argument."); return; } long seed = Long.parseLong(args[0]); Random random = new Random(seed); Scanner scanner = new Scanner(System.in); System.out.println("Enter 1 for rock, 2 for paper, and 3 for scissors."); do { int computerChoice = random.nextInt(3); int userChoice = getUserChoice(scanner); if (userChoice == -1) { continue; } System.out.println("Your choice: " + choiceToString(userChoice) + ". Computer choice: " + choiceToString(computerChoice) + "."); int result =…Write an if-else statement with multiple branches. If givenYear is 2101 or greater, print "Distant future" (without quotes). Else, if givenYear is 2001 or greater (2001-2100), print "21st century". Else, if givenYear is 1901 or greater (1901-2000), print "20th century". Else (1900 or earlier), print "Long ago". Do NOT end with newline. import java.util.Scanner; public class YearChecker {public static void main (String [] args) {Scanner scnr = new Scanner(System.in);int givenYear; givenYear = scnr.nextInt();Do a program that displays a simulated writing check.Use supplied Check.java and CheckDemo.java.It should then display a simulated check with the dollar amount spelled out,as shown. Check.Demo package checks; import java.time.LocalDate; public class Check { private double amount; private String payee; private LocalDate date; /* * Constructor */ public Check(double amount, String payee, LocalDate date) { // Your code here } public Check(Check original) { // Your code here } /* * Returns a String representing the check */ public String toString() { String result = "\t\t\t\tDate:\t"; result += date.getMonthValue() + "/"; result += date.getDayOfMonth() + "/"; result += date.getYear() + "\n\n"; result += "Pay to the Order of: " + payee + "\t\t"; result += "$" + amount + "\n\n"; result += amountText() + "\n"; return result;// return amountText(); } private…