Assign isTeenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign isTeenager with false. 2 3 public class TeenagerDetector { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); boolean isTeenager; int kidAge; 4 6. 7 8 9. kidAge scnr.nextInt(); 10 11 /* Your solution goes here */ 12 13 if (isTeenager) { System.out.println("Teen"); } else { System.out.println("Not teen"); } 14 15 16 17 18 19 20 }
Q: Write a program in Java for the below situation In a royal casino, there is a lottery at 14 number…
A:
Q: class Garden{ private int area; public Garden(int a) { area = a; } public boolean equals (Garden g)…
A: In the following code A garden class is there with area private variable and garden constructor,…
Q: UML diagram for the java code below public class CourseDBManager implements…
A: UML has a totally comprehensive notation for finite nation machines. Figure 1-6 suggests simplythe…
Q: Expand the wedding class to include six weddings. import java.time.*; public class TestWedding {…
A: import java.util.*;import java.lang.*;import java.io.*;import java.time.*; //define a class…
Q: Given the following Date class public class Date { private int year; private int month; private int…
A: In given Date Class we have Two contractor 1) non-parametric constructor 2)…
Q: In this example ,GradeBook class has one attribute and some methods to access this attribute data:…
A: We need to make a static function output in GradeBookTest. Its parameter will object of GradeBook.…
Q: Consider the following code: class Player { private: string ID; string name; public:…
A: A class is a group of objects which have common properties. A constructor is a method that is used…
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: What does the following code print out? class Main { public static void main (String[] args) { int…
A: In this question, we have given a java code. We have to find the output of the code. We will run the…
Q: import java.util.Scanner; public class Juice_ordering { public static void main(String []…
A:
Q: Q 1: Access class members from the same package Note: Classa and ClassB in this question are in the…
A: 1.1 a and b are the correct options. a. If statement 1 is uncommented, the code prints “1”…
Q: Consider the following code: class Player { private: string ID; string name; public:…
A: Here is the explanation about the access method in the given classes:
Q: For the given code below, which lines are valid (will compile and run)? Assume each line is run…
A: The problem is based on the basics of static and non-static functions in java programming language.
Q: Q27 for java programing: public static void main(String[] args) { Dog[] dogs = { new…
A: Find the required answer with explanation given as below :
Q: Consider the following code snippet. public interface Measurable { double getMeasure); } public…
A: Java provides upcasting implicitly and downcasting explicitly. If you try to do downcasting…
Q: Implement a class Robot that simulates a robot wandering on an infinite plane
A: We gave x=5, y=5, and 1 that is E at Robot robot = new Robot(new Point(5, 5), 1); In the robot…
Q: For the given code below, which lines are valid (will compile and run)? Assume each line is run…
A: Your answer is given below as you required .
Q: 1 public class Con{ public static void main(String[] args) 3- { int[] ar-{2,5,7,9}; 5 int i-2; final…
A: Error: cannot assign a value to final variable j
Q: Q 1: Access class members from the same package Note: ClassA and ClassB in this question are in the…
A: Below is the answers of both the parts:
Q: Q 1: Access class members from the same package Note: ClassA and ClassB in this question are in the…
A: In step 2, you will get the answer for 1.1. In step 3, you will get the answer for 1.2.
Q: Please fix this code. 4.6.1: Overload salutation printing. Complete the second printSalutation()…
A: Coded using Java Language.
Q: Assuming we have class z: class z { public string d1; public string d2; public void show() {…
A: To display multiple variables value in C#, you need to use the comma operator in…
Q: Consider the following class: 1 public class Student { 2 private int studentNumber; 3 private…
A: OOP or Object-Oriented Programming is a software model that is designed around data or objects…
Q: public class AverageWithSentinel public static final int END_OF_INPUT = -500'; %3D public static…
A:
Q: public class output[ public static void main(String[] args) { int [][] D= new int [3][3]; int [] c =…
A: - We need to talk about the program and produce it's output.
Q: Assign isTeenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign isTeenager with…
A: When you mean inclusive, you have to use the symbols <= less than or equal to and >= greater…
Q: What does the method printStuff) print? public class Vehicle public String tostring () return…
A: Please refer to the following steps for the complete solution of the problem above.
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: ch of them and explain why output would be that. [10] class P{ public int x; } class G{ private P…
A: EXPLANATION The first new object p is created. Then object g is created by passing object reference…
Q: . In this java program, explain everyline of this code. Source Code: import java.util.*; public…
A: Algorithm: 1)This program randomly generates two number between 0 to 4 and assign it to array arr at…
Q: Consider the following code: class Player { private: string ID; string name; public:…
A: Actually, object is a instance of class.
Q: Consider the following classes: public class AA{ public int foo(int x) { return x-1; } } public…
A: Here we are explaining the code:-…
Q: Given: 1. public class Foo { 2. public static void main (String[] args) { 3. int i = 1: 4. int j…
A: In this question we have to find the related output for the following code given in JAVA programming…
Q: int main() { Player golfer("Tiger Woods", "123456789"); BasketballPlayer…
A: The answer is given below
Q: // Example.java: class Example { public static void exampleFun() Rectangle s- new Rectangle(5,7);…
A: Option B) in Example.java instead of : ss.length = 10;it should be ss.setLength(10);
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: Describe the code : Player(n, i) at the end of the BasketballPlayer constructor. a. calls the…
A: Answer:- A) calls the Player constructor with parameters n, i
Q: For the code below: public class College extends Student { public static void main(String[ ] args)…
A: 1- Constructor Chaining:
Q: Consider the following instance variables and method from a class: private String descriptor; public…
A: Given descriptor is "regular" Called makeSentence(3, false) Thus, quant=3, sign=false
Q: Assuming we have class z: class z { public string d1; public string d2; public void show() {…
A: Hello Student. Warm greetings from my side. Hope you are doing great. Here is your answer.
Q: **JAVA LANGUAGE** beginner level import java. util.Arrays; import java.util.Scanner; Suppose that…
A: import java.util.Scanner;class Main{ static double priceIsRight(Scanner s, double price){…
Q: **JAVA LANGUAGE** Beginner Level Suppose that a Scanner object contains a bunch of tokens all on…
A: Steps followed for partialSum method: Declaring and initializing the total variable and X…
Q: public class X{private int x,y; public void m1(boolean b) {x>>=1;y--;}return z;}public void…
A:
Q: Consider the following code: class Player { private: string ID; string name; public:…
A: Given, Player golfer("Tiger Woods", "123456789"); // line 2 BasketballPlayer…
Q: I have problems with the Java code in: package testapartment; import java.util.Scanner; public…
A: Given: I have problems with the Java code in: package testapartment; import java.util.Scanner;…
Q: 1 import java.util.Scanner; 2 3 public class MaxOf Two { 4 5 6 7 8 9 .0 1 _2 min 6 3 4 5 -6 7 .8 _9}…
A: In method getUserValues, we will use for loop that varies from 0 to array size -1 to input array…
Q: A new deadly virus has infected large population of a planet. A brilliant scientist has discovered a…
A: So as per the question logic for code should be, vaccine count of midichlorains will be higher than…
Q: java program Write the equals method for Circle2 which returns true when the radius and the color…
A: Find the required code given as below and required output :
Q: Q4) Write the output of the following code segment public class CarStatic { public static void main…
A: In the above program, getInfo() is non static method. But we call that method using Class name.
Q: import java.awt.*; public class TestRectangle { public static void main(String[] args) { Rectangle…
A: PROGRAM: //Defining class class Rectangle { //Declaring variables int x; int y;…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- Assign isTeenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign isTeenager with false. 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 public class TeenagerDetector { publicstaticvoidmain (String [] args) { Scannerscnr=newScanner(System.in); booleanisTeenager; intkidAge; kidAge=scnr.nextInt(); if ( (kidsAge>13) && (kidsAge<19), { isTeenager=true; } elseif { isTeenager=false; } if (isTeenager) { System.out.println("Teen"); } else { System.out.println("Not teen"); }Define the missing method. Use "this" to distinguish the local member from the parameter name. // ===== Code from file CablePlan.java =====public class CablePlan {private int numDays; // FIXME: Define setNumDays() method, using "this" implicit parameter.public void setNumDays(int numDays) { /* Your solution goes here */ } public int getNumDays() {return numDays;}}// ===== end ===== // ===== Code from file CallCablePlan.java =====import java.util.Scanner; public class CallCablePlan {public static void main(String [] args) {Scanner scnr = new Scanner(System.in);CablePlan house1Plan = new CablePlan();int userNum; userNum = scnr.nextInt();house1Plan.setNumDays(userNum);System.out.println(house1Plan.getNumDays());}}// ===== end =====**JAVA LANGUAGE** Beginner Level Suppose that a Scanner object contains a bunch of tokens all on a single line separated by spaces. For example: 100.5 65 pizza 100 45.75 70 5.8 5 Also suppose that you have two integers n and m that are both positive. For example: n = 5 and m = 10 Write a static method: public static double partialSum(Scanner s, int n, int m) that takes a Scanner and two integers n and m as arguments and returns the sum of the integers read by the Scanner that are divisible by n and not divisible by m. In the above example, the integers divisible by 5 and not divisible by 10 are 65 and 5, so the result would be 70. If the Scanner is empty, or no tokens are valid integers, the result should be 0. You can assume the Scanner is not null. It is probably easiest to test your method by creating a Scanner with a String instead of System.in. Tests to include in your main method: Test the above example with “100.5 65 pizza 100 45.75 70 5.8 5” as the…
- import java.util.Scanner; public class PetInformation {public static void main(String[] args) {Scanner scnr = new Scanner(System.in); Pet myPet = new Pet(); Cat myCat = new Cat(); String petName, catName, catBreed; int petAge, catAge; petName = scnr.nextLine(); petAge = scnr.nextInt(); scnr.nextLine(); catName = scnr.nextLine(); catAge = scnr.nextInt(); scnr.nextLine(); catBreed = scnr.nextLine(); // Create generic pet (using petName, petAge) and then call printInfo myPet.setName(petName); myPet.setAge(petAge); myPet.printInfo(); // Create cat pet (using catName, catAge, catBreed) and then call printInfo myCat.setName(catName); myCat.setAge(catAge); myCat.setBreed(catBreed); myCat.printInfo(); // Use getBreed(), to output the breed of the cat System.out.println(" Breed: " + myCat.getBreed());}}import java.awt.*; public class TestRectangle {public static void main(String[] args) {Rectangle r1 = new Rectangle(5, 4, 10, 17);Rectangle r2 = new Rectangle(10, 10, 20, 3);Rectangle r3 = new Rectangle(0, 1, 12, 15);Rectangle r4 = new Rectangle(10, 10, 20, 3);System.out.println("r1 = " + r1);System.out.println("r2 = " + r2);System.out.println("r3 = " + r3);System.out.println("r2 equals r1? " + r2.equals(r1));System.out.println("r2 equals r2? " + r2.equals(r2));System.out.println("r2 equals r3? " + r2.equals(r3));System.out.println("r2 equals r4? " + r2.equals(r4)); System.out.println("r1 contains (6, 8)? = " + r1.contains(6, 8));System.out.println("r2 contains (6, 8)? = " + r2.contains(6, 8));System.out.println("r3 contains (6, 8)? = " + r3.contains(6, 8));System.out.println("r2 contains (30, 13)? = " + r2.contains(30, 13)); r1.intersect(r3);r2.intersect(r4);System.out.println("r1 intersect r3 = " + r1);System.out.println("r2 intersect r4 = " + r2);…JAVA Implement the equals method of the Arrow class. Two arrows are equal when they have the same starting point and direction. public class Arrow{ private Point start; private String direction; /** Constructs an arrow. @param x the x-position @param y the y-position @param direction a compass direction N E S W NE NW SE SW */ public Arrow(int x, int y, String direction) { start = new Point(); start.move(x, y); this.direction = direction; } /** Checks whether this arrow is equal to another. @param otherObject another arrow @return true if this arrow and otherObject have the same position and direction. */ public boolean equals(Object otherObject) { /* code goes here */ }}
- Beginner Java import java.util.Arrays;import java.util.Scanner; Arrays and scanner required. Suppose that a Scanner object contains a bunch of tokens all on a single line separated by spaces. For example: 100.5 65 pizza 100 45.75 70 5.8 5 Also suppose that you have two integers n and m that are both positive. For example: n = 5 and m = 10 Write a static method: public static double partialSum(Scanner s, int n, int m) that takes a Scanner and two integers n and m as arguments and returns the sum of the integers read by the Scanner that are divisible by n and not divisible by m. In the above example, the integers divisible by 5 and not divisible by 10 are 65 and 5, so the result would be 70. If the Scanner is empty, or no tokens are valid integers, the result should be 0. You can assume the Scanner is not null. It is probably easiest to test your method by creating a Scanner with a String instead of System.in. The starter code for an example of how to do this is…Please ASaP. 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);}} .Trace and document every step of execution of the following program: public class Trace { public static void main(String[] args) { int[] num = {1, 3, 6, 9, 12 }; for (int i = 4; i >= 0; i--) { num[i] +=1; } num[0] *=num[4]; } }
- Class Die java.lang.Objectextended by Diepublic class Dieextends java.lang.ObjectDie - an n-sided die with given integer values. The given integer values are returned via nextRoll() with uniform probability., Constructor SummaryDie() Creates a new Die instance with the default values: 1, 2, 3, 4, 5, 6.Die(int[] outcomes) Creates a new Die instance with the given integer outcomes.Die(int sides, int min) Creates a new Die with a given number of sides and an incremental sequence of values beginning with a given minimum value.Method Summaryint nextRoll() nextRoll - return one of the die values at random.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitConstructor DetailDie public Die(int[] outcomes)Creates a new Die instance with the given integer outcomes.Parameters:outcomes - an int[] value - an array of the integer values for each side of the die.Die public Die(int sides,int min)Creates a new Die with…HW 4 Code (In Java) import java.util.Scanner;class Movie {private String name;private String mipaaRating;private int terrible;private int bad;private int ok;private int good;private int great;public Movie(String name, String mipaaRating) {this.name = name;this.mipaaRating = mipaaRating;this.terrible = 0;this.bad = 0;this.ok = 0;this.good = 0;this.great = 0;}//Adding the ratings for Terrible to Excellent ratingpublic void addRating(int rating) {if (rating >= 1 && rating <= 5) {switch (rating) {case 1:this.terrible++;break;case 2:this.bad++;break;case 3:this.ok++;break;case 4:this.good++;break;case 5:this.great++;break;}}}// Finds the average for every single rating when givenpublic double getAverage() {int total = this.terrible + this.bad + this.ok + this.good + this.great;if (total == 0) {return 0;} else {double sum = this.terrible + (2 * this.bad) + (3 * this.ok) + (4 * this.good) + (5 * this.great);double avg = sum / total;return Math.round(avg * 100.0) /…Here is my code in Java: import java.util.Scanner; import java.util.HashMap; public class Inventory { /** This class demonstrates the inventory */ //Declarations Of inventory static final int LightBulb60W = 1; static final int LightBulb100W = 2; static final int BoltM5 = 3; static final int BoltM8 = 4; static final int Hose25 = 5; static final int Hose50 = 6; public static void main (String [] args) { //Scanner Object @SuppressWarnings("resource") Scanner keyboard = new Scanner(System.in); //Variables int month; int day; int year; double units; double cost = 0; //Declarations int total; HashMap<Integer, String> productMap = new HashMap<>(); productMap.put(1,"Light Bulb 60W"); productMap.put(2,"Light Bulb 100W"); productMap.put(3,"Bolt M5"); productMap.put(4,"Bolt M8"); productMap.put(5,"Hose 25 feet"); productMap.put(6,"Hose 50 feet 60W"); while(true){ //Prints out inventory System.out.println("The Inventory: "); System.out.println("1…