Write an if-else statement for the following: If userTickets is less than 5, execute awardPoints = 1. Else, execute awardPoints = userTickets. Ex: If userTickets is 3, then awardPoints = 1. 1 import java.util.Scanner; 2 3 public class TicketCounter { public static void main (String [] args) { int awardPoints; int userTickets; 4 5 7 Scanner scnr = new Scanner(System.in); userTickets = 8 9. scnr.nextInt(); // Program will be tested with values: 3, 4, 5, 6. 10
Q: Write complete java code for scenario given: Consider a Java class that you could use to get an…
A: Program Plan: • Define a class called AcceptedIntegerValue. o Declare the three variables one to…
Q: In Java trace the table for the do while loop public class Main { public static void main(String[]…
A: According to the Question below the Solution:
Q: Modify the Java CountByFives application so that the user enters the value to count by. Start each…
A: public class CountByAnything{ public static void main (String args[]) { final int START…
Q: public class ReversedDigit { public static void main(String[] args) { Scanner scan =…
A: The do-while loop is a variant of the while loop.
Q: plain this java code
A: Descriptions: 1- Please check the following updated code with comments line by line. 2- There are…
Q: Print either "Fruit" or "Drink" (followed by a newline) depending on the value of userltem. For…
A: The answer is given below:-
Q: hasAnEvenDigit: Takes an int (n) as parameter and returns whether n has at least one digit whose…
A: Program description: The Main.java program test the method, hasAnEvenDigit. The method,…
Q: public class Password { String password; String SPECIAL_SYMBOLS = "!@#$%^&*"; public boolean…
A: import java.util.*; class Password { String password;String SPECIAL_SYMBOLS = "!@#$%^&*"; public…
Q: This must be done in Java.util.scanner. Class. Everything must have comments Write a Java…
A: ALGORITHM:- 1. Take input from the user. 2. Generate the random number between 1 and 10. 3. Display…
Q: Below is the CustomerNumber Program. In the attached pictures is the assignment I am struggling…
A: import java.util.Scanner; public class CustomerNumber{ public static void main(String[] args){…
Q: amount the same, y, n, why? public class CheckingAct { private String actNum;…
A: 1. If you declare any variable in the methods then they are local variable and scope of variable is…
Q: Complete the code in the Practice class such that each time the user clicks the SUM button, the sum…
A: We need to fix the code: See below step for code and output
Q: Write an if-else statement to describe an object. Print "Balloon" if isBalloon is true and isRed is…
A: import java.util.Scanner; public class RedBalloon { public static void main (String [] args) {…
Q: // This class discounts prices by 10% public class DebugFour4 { publicstaticvoidmain(Stringargs[]) {…
A: package Java.C.c; publicclassLongestLine { public static void main(String args[]) { final double…
Q: public static int myMethod (int y, int z) { if (y > z) return y * z; else return myMethod (y - 2,…
A: In this problem, we need to give a condition when will the stack overflow condition will occur.…
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: In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the…
A: A C++ program to compute the area and perimeter of a rectangle using class structure.
Q: Write code that outputs variable numBaths as follows. End with a newline. Ex: If the input is: the…
A: 1. Importing scanner class 2. Declaring a variable numbaths. 3. Asking the user to enter the input…
Q: problem description and answer all the questions about it: Problem Description: In the following…
A: Objective: This program modifies the given code and displays the bill using the factory design…
Q: Write the unit tests class for the given Java program: public static void main(String[] args) {…
A: Answer:
Q: public void foo4() { String s2 = "smith"; String s3 = s2; String s4 = null; String s5 = ""; String…
A: EXPLANATION: The == operator in String is used to compare the references of two strings to see if…
Q: U is upward, D is downward, L is left and R is right : Using the methods pickDir() and exractInt()…
A: The program is written in java. MAXLOOPS is set to 20.
Q: Write an expression that prints "Special number" if specialNum is -99, 0, or 44. 1 import…
A: File name: “FindSpecialValue.java” import java.util.Scanner; public class FindSpecialValue {…
Q: A cashier distributes change using the maximum number of five dollar bills, followed by one dollar…
A: Remainder(%) operator: The percentage symbol(%) is java is called a modulo operator or remainder…
Q: This problem is inspired by the book's Problem P6.10 on page 304. You are to write an application to…
A: the answer is given below:-
Q: Complete method printPopcornTime(), with int parameter bagOunces, and void return type. If bagOunces…
A: A Java program for the given criteria is as follows, File name: “PopcornTimer.java” //Import the…
Q: Write multiple if statements: If carYear is before 1968, print "Probably has few safety features."…
A: Declare a class SafetyFeatures. Inside main() method. Declare an integer variable, carYear.…
Q: * Constructor for objects of class SimpleBankAccount public SimpleBankAccount (){ balance- 0.0; ac…
A: Given that:
Q: Question public class MyProgram ( if (h 30) system.out.print("Evening"); t = t + 5;…
A: I have provided the answer based on java Programming. Detailed comments are included for a better…
Q: Write an expression that will cause the following code to print "less than 18" if the value of…
A: In this Java code, we have to write the if condition for that print the desired output. we have to…
Q: public class TestAverage {public static void main(String[] args) {int test1, test2, test3,…
A: The objective of the program is to calculate the average, now since the variable which holds the…
Q: Start with the code below and complete the getInt method. The method should prompt the user to enter…
A: throw is the keyword used to explicitly throw an Exception
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: Duke Shirts sells Java t-shirts for $24.95 each, but discounts are possible for quantities as…
A: Java Code:- import java.util.*; public class Main { public static void main(String[] args)…
Q: Write an application that counts by five from 5 through 500 inclusive, and that starts a new line…
A: Program Approach: Defining a class as public within which the function main is defined. In the main…
Q: To compare if the original cells are kept in the cells * * For example, cell 1 1 in original cell is…
A: Program1 class Test{ public static void main(String[] args) { int[] arr=…
Q: Modify the CountByFives application so that the user enters the value to count by. Start each new…
A: Given: A code snippet in Java containing a method that prints numbers counted by 'five'. Objective:…
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: // Return the reversal of an integer public static int reverse(int number) // Return true if number…
A: Hi. Let's move on to the code in the next step. I have included comments in the code that will…
Q: Write an expression that will cause the following code to print 'I am an adult" if the value of…
A: Step 1: Input age from the user. Step 2: If the age is less than or equal to 19, then display the…
Q: Write a statement that assigns finalResult with the sum of num1 and num2, divided by 3. Ex: If num1…
A: Here have to determine java code for given problem.
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: Create a flowchart base on the source code source code: import java.util.Scanner; public class…
A: The flow chart is a pictorial representation of the flow of the program. The flow chart is…
Q: Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E"…
A: Answer:
Q: canMove(int x, int y, int destX, int destY, Side s): This method returns true if the player of color…
A: using namespace std; // function to Find the minimum number of moves required to // reach the…
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: Consider a vending machine
A: #include<iostream>#include<string> using namespace std; struct item { string name;…
Q: In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the…
A: - The question wants us to code for the area finding problem in C++.
Q: Write a statement that assigns finalResult with the sum of num1 and num2, divided by 3. Ex: If num1…
A: The answer is given below.
i need help with coding
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- 2.1.3: Basic if-else. Jump to level 1 Write an if-else statement for the following: If userTickets is less than 8, execute awardPoints = 1. Else, execute awardPoints = userTickets. Ex: If userTickets is 3, then awardPoints = 1. import java.util.Scanner; public class TicketCounter { public static void main (String [] args) { int awardPoints; int userTickets; Scanner scnr = new Scanner(System.in); userTickets = scnr.nextInt(); // Program will be tested with values: 5, 6, 7, 8. if (userTickets < 8) { awardPoints = 1; System.out.println(awardPoints); } else { System.out.println(awardPoints); }}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();Duke Shirts sells Java t-shirts for $24.95 each, but discounts are possible for quantities as follows: 1 or 2 shirts, no discount and total shipping is $6.993-6 shirts, discount is 10% and total shipping is $5.497-9 shirts, discount is 20% and total shipping is $4.0010 or more shirts, discount is 30% and shipping is free Write a Java program that prompts the user for the number of shirts required. The program should then print the extended price* of the shirts, the shipping charges, and the total cost of the order. Use currency format where appropriate. *Note extended cost is the unit cost multiplied by the number of those items that were purchased with the discount applied
- Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A, B, C, D, E" is correct. Each question has one correct answer. Thank you. Part 1 - Given the following code, the output is __. class Sample{ public static void main (String[] args){ try{ System.out.println(5/0);}catch(ArithmeticException e){ System.out.print("Divide by zero????");}finally{ System.out.println("5/0"); } }} A. Divide by zero????B. 5/0C. Divide by zero????5/0D. 5/0Divide by zero????E. "5/0" Part 2 - Given the following code, the output is __. try{ Integer number = new Integer("1"); System.out.println("An Integer instance.");}catch (Exception e){ System.out.println("An Exception.");} A. An Integer instance.B. An Exception.C. 1D. Error: ExceptionE. None of the optionsIn C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Print out the area of the rectangle.In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Set the length of the rectangle to 24 and the width to 30.
- // ArtShow.java - This program determines if an art show attendee gets a 5% discount // for preregistering. // Input: Interactive. // Output: A statement telling the user if they get a discount or no discount. import java.util.Scanner; public class ArtShow { public static void main(String args[]) { Scanner s = new Scanner(System.in); String registerString; System.out.println("Did you preregister? Enter Y or N: "); registerString = s.nextLine(); // Test input here. If Y, call discount(), else call noDiscount(). System.exit(0); } // End of main() method. // Write discount method here. // Write noDiscount method here. } // End of ArtShow class.Java Program PLEASE FIX AND MODIFY THIS JAVA SO WHEN I UPLOAD IT TO HYPERGRADE IT PASSES ALL TEST CASSES PLEASES. RIGHT NOW IT SAYS 0 OUT 5 PASSED. THE PICTURES THAT I PROVIDED PROOF THAT WHEN I UPLOAD IT TO HYPERGRADES IT FAILS TEST CASSES. THANK YOU import java.util.Scanner;public class RetailPriceCalculator { public static double calculateRetail(double wholesale, double percentage) { double retailPrice = wholesale + wholesale * (percentage / 100); return retailPrice; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); double wholesale = 0; double percentage = 0; // To check if it is the first or second input error int n = 0; boolean wholeSale = true; boolean percent = true; boolean condition = true; while (condition) { while (wholeSale) { // loop to prevent invalid input for wholesale if (n == 0) {…Write an application that counts by five from 5 through 500 inclusive, and that starts a new line after every multiple of 50 (50, 100, 150, and so on). public class CountByFives { public static void main (String args[]) { // Write your code here } }
- 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);}}}This is the question - Write an application that counts the total number of spaces contained in a quote entered by the user. This is the code I have. The issue it seems to be counting like: "The number of spaces is 0 The number of spaces is 0 The number of spaces is 0 The number of spaces is 1 The number of spaces is 1 The number of spaces is 1", rather than just saying it once with the final number of spaces. This is my code - import java.util.*; public class CountSpaces2 { public static void main(String[] args) { // Write your code here Scanner input = new Scanner(System.in); int i; String quote; System.out.println("Please enter your quote "); quote = input.nextLine(); int numSpaces=0; for(i=0; i<quote.length();i++) { char ch=quote.charAt(i); if(ch == ' ') numSpaces++; System.out.println("The number of spaces is " +numSpaces); } } }Write a program that displays a simulated writing check.The program should accept inputs of the date, the payee's name, and the amount of the check.Use supplied Check.java and CheckDemo.java.It should then display a simulated check with the dollar amount spelled out,as shown. Check.java 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…