Write an if-else statement for the following: If userTickets is greater than 8, execute awardPoints = 10. Else, execute awardPoints = userTickets. Ex: If userTickets is 14, then awardPoints = 10. 1 import java.util.Scanner; 2 3 public class TicketCounter { public static void main (String [] args) { int awardPoints; int userTickets; 4 6. 7 Scanner scnr = new Scanner(System.in); userTickets 8 9. scnr.nextInt(); // Program will be tested with values: 6 %3D 10 11 /* Your code goes here */ 12 System.out.println(awardPoints); } 13 14 15 }
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: One Computer Science program uses the following rules tor CS course placement: 1. if the CS AP score…
A: Objective: This program determines CS placement for students depending on certain given rules. The…
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: Write an application that prompts the user for three first names and concatenates them in every…
A: Given: Three first names for new-born babies Objective: The aim of this program is to print all the…
Q: s shown in the Figure. (Hint: A point is in the rectangle if its horizontal distance to (0, 0) is…
A: Analysis of the problem: There is a rectangle with vertices a,b,c,d(let). The position of the…
Q: Write an application that asks a user to type an even number or the sentinel value 999 to stop. When…
A: CODE : import java.util.*; public class EvenEntryLoop { public static void…
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: 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 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: Write a statement that increases numPeople by 5. Ex: If numPeople is initially 10, the output is:…
A: According to the guideline we are allowed to answer only the first question. - The first question…
Q: public class output{ public static int check (int a, int b, int c) { if(a==0) return (b); else if…
A: Given:
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: public class PSP6 { public static void main(String[] args) { System.out.println(finalCarPrice(1));…
A: According to the Question below the Solution: Output:
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: 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: Mad Libs is a game where the player selects words based on part of speech that are then used to fill…
A: In the given code below Declare the variable holder as a string. Declare the List name input of the…
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: In C++ class rectangleType { public: void setLengthWidth(double x, double y); //Sets the…
A: The problem is based on the basics of classes in C++ programming language.
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: Lab Work 2 In this lab work, you will implement a coffee shop example. In this coffee shop,…
A: To create: To write a menu-driven C program for a coffee shop that asks the user the number of…
Q: Write a method that checks whether two words are anagrams. Two words are anagrams if they contain…
A: #include <bits/stdc++.h>using namespace std; bool areAnagram(string str1, string str2){ int n1…
Q: b. Weight c. Height 2. Compute the BMI of that individual 3. Make the following decisions if:…
A: Define packages java.util and java.lang for i/o operations and fundamental classes respectively…
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: Using Java programming language write a program to manage a hotel with 24 rooms; 10 rooms are…
A: Given 10 rooms are Executive, with price Gh ₵ 2500.00 per night,7 rooms are Chalets, with amounts…
Q: Write a simple calculator which supports add subtract multiply and divide. Prompt the user for two…
A: Java program to make a simple calculator and prompt the user to choose an operation from the given…
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 JavaApplication7 { public static void main(String [] args) { //TODO - write your own…
A: public class Main{ public static void main(String[] args) { //testing method…
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: 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 a program that takes a decimal value between 1 and 10 and displays its equivalent Roman…
A: 1) take input from the user 2)use one class to check the input define as check class 3) And other…
Q: Write a JAVA program that can be used to assign seats for a commercial airplane. The airplane has 13…
A: The required java code for given problem is given below- //Code begins import java.util.*;import…
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: 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 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: Develop a letter-guessing game in this assignment. Requirements: 1). When the game begins, generate…
A: The java code is given below:
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 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: Using Java programming language write a program to manage a hotel with 24 rooms; 10 rooms are…
A: It is defined as
Q: Write an enum type TrafficLight, whose constants (RED, GREEN, YELLOW) take one parameter the…
A: Java used to answer this question
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: 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.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- 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
- 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; }; Print out the area of the rectangle.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; }; Set the length of the rectangle to 24 and the width to 30.
- 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) {…// 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.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 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 } }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…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);}}}