public class DebugBox
Q: Given main(), define a Course base class with methods to set and get private fields of the following…
A: The question asks to create a Java program that represents course information, including details…
Q: tity; private int capacity; private int seatsTaken; public DesertEvent(String eventName, String…
A: Here is a possible implementation of the Driver class (TestDesertEvent):
Q: class TenNums { private: int *p; public: TenNums
A: Dear Student, The answer to your question is given below -
Q: import java.util.Scanner; 2 public class BMICalculation { Y 1 23456 3- 7 68 9 10 11 12 13 } public…
A: The class BMI that you defined may be to blame for the problem. It would be preferable if you had…
Q: import java.util.Scanner; public class WinningTeam { public static void main(String[] args) {…
A: Class Definition:Define a class named Team.Declare private instance variables: name (String), wins…
Q: import java.util.Arrays; import java.util.Scanner; public class Game { private Player[]…
A: In Java, an exception which refers to the one it is an event that occurs when an error condition is…
Q: /VotingMachine.java:63: error: class Assignment03 is public, should be declared in a file named…
A: Here this program might run by removing the public access specifier in the class Assignment03.
Q: public class Shape { Color fillColor; } public Shape() } fill Color = Color. RED; } public…
A: Lets talk about shape class(which is base class of Circle class): -->having attribute/data…
Q: public class Errors { public static void main (String[] args) { System.out.println("Welcome to my…
A: Errors System.out.println("Welcome to my first program!\n") // semicolon missing Correct one…
Q: The base class Pet has protected fields petName, and petAge. The derived class Cat extends the Pet…
A: The main() method of a program that makes instances of the Pet and Cat classes and prints their…
Q: public class Number { private int num; public Number(int n) { num = n; } /*…
A: 1. Import the Scanner class for user input.2. Define a `LabProgram` class.3. Inside the `LabProgram`…
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: /* TestCarSensor.java - program to test the CarSensor class. */ public class TestCarSensor { public…
A: Errors in CarSensor.java: The class had below errors: Data type was missing for data member: error,…
Q: Creates a frame with the specified size // that is twice as tall as wide import javax.swing.*;…
A: In the given code there are three errors, i update the code to be bug free.
Q: Fix this program import java.util.Scanner; public class main { public static void…
A: All the errors are fixed in the code The correct code is given below with OUTPUT screenshot Happy to…
Q: public class Car { public void m1( { Sustem.Qut.printla("car 1"); } public void m2() { super.m1(); }…
A: answer is
Q: public class TestWord { public static void main(String[] args) { /* Word w1 = new Word("Go Cubs Go",…
A: Answer: We have done code in java programming language and we have also attached code and code…
Q: import java.util.Scanner; public class WinningTeam { public static void main(String[] args) {…
A: Dear student in Team.java class set methods were not correct. Now corrected and program is working…
Q: public class Stadium extends baseStadium{ public int typeTicket; int floors; int seating;…
A: The code includes three classes: Stadium, ticket, and baseStadium, and one interface TicketService.…
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: public class LabProgram { public static void main(String args[]) { Course cis162 = new Course();…
A: The Course class has an instance variable roster which is an ArrayList of Student objects.The Course…
Q: Neight(lb): " + shipWeightPounds); lat foofconte)" ELAT EEE CENTS). w. Special character legend…
A: I have answered below:
Q: PlayerRoster.java:139: error: class, interface, or enum expected import java.util.Scanner;…
A: We need to rectify the errors in the given Java code.
Q: public class CallStack{ // Called by func1() void func2 (){ System.out.println("In…
A: According to the information given:- We have to examine the code and handle the exception by…
Q: package assignment; public class Circle2D2 { //data fields specifying the center of the circle…
A: Actually, program is executable software that runs on a computer.
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: Complete the seperateDuplicateChars() method in SeperateDuplicates.java as follows: - The method…
A: Here's the implementation for seperateDuplicatesChars() method: CODE: public static String…
Q: import java.awt.*; public class TestRandomWalker { public static final int STEPS = 500; public…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: //PLEASE CORRECT MY MISTAKES, THANK YOU public class Person { private String personID; private…
A: As per the question, solution is mentioned below:
Q: Complete the missing line of code: public class Rectangle { private int width; private int height;…
A: The problem is based on parameterised constructors in C++ language.
Q: 1 a. is the amount the same, yes or no, why? public class CheckingAct { private String…
A: As per my company rule, I can solve the first three subheadings only. please post the remaining as a…
Q: import java.util.Scanner; public class MealEstablishmentDirectory { public static void main…
A: Java class named MealEstablishment with three methods: setRating, setState, and print. These methods…
Q: Q1. amount the same, y, n, why? public class CheckingAct { private String actNum; private…
A: Dear Student, We valued your time. But as per guidelines, I can give answer only to the first…
Q: public class KnowledgeCheckTrek { public static final String TNG = "The Next Generation";…
A: We need to find the correct option regarding the given Java code.
Q: class temporary { public: void set(string, double, double); void print(); double manipulate();…
A: Algorithm:Include necessary libraries:Include the required C++ libraries for input and output…
Q: Complete the isExact Reverse() method in Reverse.java as follows: The method takes two Strings x and…
A: Complete the isExactReverse() method in Reverse.java as follows: The method takes two Strings x…
Q: what is wrong with my code I need help pls make it in the correct format and explain what is wrong…
A: import java.util.Scanner; public class Movie { private String name; private double rating;…
Q: Given a base Plant class and a derived Flower class, complete main() to create an ArrayList called…
A: Algorithm:Create an empty ArrayList called myGarden to hold Plant or Flower objects.Initialize an…
Q: class temporary { public: void set(string, double, double); void print(); double manipulate();…
A: Algorithm:Include necessary libraries:Include the required C++ libraries for input and output…
Q: Public Class SavingsAccount { float interest; float FixedDeposit; SeniorAccount(float…
A: A syntax error is the error in the program which is made typing mistakes by the user and logical…
Q: public class SidePlot { public static String PLOT_CHAR = "*"; public static void main(String[] args)…
A: I have provided JAVA CODE along with CODE SCREENSHOT and OUTPUT SCREENSHOT------
Q: CHAPTER 10 Object-Oriented C++ method to calculate and return the area of the rectangle and the…
A: Algorithm : Rectangle.cpp file Rectangle class : Step 1 : under private access specifier , declare…
Q: complete the missing code. public class Exercise09_04Extra { public static void main(String[] args)…
A: After completing the code, I have provided JAVA CODE along with CODE SCREENSHOT and OUTPUT…
Q: Complete the Course class by implementing the printRoster() method, which outputs a list of all…
A: Create a Course object representing a course.Initialize variables first, last, and gpa to store…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- import java.util.Scanner; public class leapYearLab { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int userYear; boolean LeapYear; System.out.println("Enter the year"); userYear = scnr.nextInt(); isLeapYear(userYear); //if leap year if (isLeapYear){ System.out.println(userYear + " - leap year"); } else{ System.out.println(userYear + " - not a leap year"); } scnr.close(); } public static boolean isLeapYear(int userYear){ boolean LeapYear; /* Type your code here. */ if ( userYear % 4 == 0) { // checking if year is divisible by 100 if ( userYear % 100 == 0) { // checking if year is divisible by 400 // then it is a leap year if ( userYear % 400 == 0) LeapYear = true; else LeapYear = false; } // if the year is not divisible by 100 else…public class Course { private String courseNumber, courseTitle; public Course() { } public Course(String courseNumber, String courseTitle) { this.courseNumber = courseNumber; this.courseTitle = courseTitle; } public void setCourseNumber(String courseNumber) { this.courseNumber = courseNumber; } public void setCourseTitle(String courseTitle) { this.courseTitle = courseTitle; } public String getCourseNumber() { return courseNumber; } public String getCourseTitle() { return courseTitle; } public void printInfo() { System.out.println("Course Information: "); System.out.println(" Course Number: " + courseNumber); System.out.println(" Course Title: " +…public class Book { protected String title; protected String author; protected String publisher; protected String publicationDate; public void setTitle(String userTitle) { title = userTitle; } public String getTitle() { return title; } public void setAuthor(String userAuthor) { author = userAuthor; } public String getAuthor(){ return author; } public void setPublisher(String userPublisher) { publisher = userPublisher; } public String getPublisher() { return publisher; } public void setPublicationDate(String userPublicationDate) { publicationDate = userPublicationDate; } public String getPublicationDate() { return publicationDate; } public void printInfo() { System.out.println("Book Information: "); System.out.println(" Book Title: " + title); System.out.println(" Author: " + author); System.out.println(" Publisher: " + publisher); System.out.println(" Publication…
- class TenNums {private: int *p; public: TenNums() { p = new int[10]; for (int i = 0; i < 10; i++) p[i] = i; } void display() { for (int i = 0; i < 10; i++) cout << p[i] << " "; }};int main() { TenNums a; a.display(); TenNums b = a; b.display(); return 0;} Continuing from Question 4, let's say I added the following overloaded operator method to the class. Which statement will invoke this method? TenNums TenNums::operator+(const TenNums& b) { TenNums o; for (int i = 0; i < 10; i++) o.p[i] = p[i] + b.p [i]; return o;} Group of answer choices TenNums a; TenNums b = a; TenNums c = a + b; TenNums c = a.add(b);package citytech.calculator; public class Calculator { public static void main(String[]args) { System.out.println("Basic Calculator"); //declaring variable: //dataType variableName = value ; double num1 = 10.0; double num2 = 30.0; sum(num1, num2); multiply(num1, num2); } public static void sum(double n1, double n2) { double result = n1 + n2; System.out.println("Sum: "+result); } public static void multiply(double n1, double n2) { double result = n1 * n2; System.out.println("Multiply: "+result); } } Question: Please Check the Calculator app and add subtract and division methods// This class discounts prices by 10% public class DebugFour4 { public static void main(String args[]) { final double DISCOUNT_RATE = 0.90; int price = 100; double price2 = 100.00; tenPercentOff(price DISCOUNT_RATE); tenPercentOff(price2 DISCOUNT_RATE); } public static void tenPercentOff(int p, final double DISCOUNT_RATE) { double newPrice = p * DISCOUNT_RATE; System.out.println("Ten percent off " + p); System.out.println(" New price is " + newPrice); } public static void tenPercentOff(double p, final double DISCOUNT_RATE) { double newPrice = p * DISCOUNT_RATE; System.out.println"Ten percent off " + p); System.out.println(" New price is " + newprice); } }
- public class Car { private int modelYear; // TODO: Declare purchasePrice field (int) private int currentValue; public void setModelYear(int userYear){ modelYear = userYear; } public int getModelYear() { return modelYear; } // TODO: Define setPurchasePrice() method // TODO: Define getPurchasePrice() method public void calcCurrentValue(int currentYear) { double depreciationRate = 0.15; int carAge = currentYear - modelYear; // Car depreciation formula currentValue = (int) Math.round(purchasePrice * Math.pow((1 - depreciationRate), carAge)); } // TODO: Define printInfo() method to output modelYear, purchasePrice, and currentValue } import java.util.Scanner;import java.lang.Math; public class CarValue { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Car myCar = new Car(); int userYear = scnr.nextInt(); int userPrice = scnr.nextInt(); int…8) Now use the Rectangle class to complete the following tasks: - Create another object of the Rectangle class named box2 with a width of 100 and height of 50. Note that we are not specifying the x and y position for this Rectangle object. Hint: look at the different constructors) Display the properties of box2 (same as step 7 above). - Call the proper method to move box1 to a new location with x of 20, and y of 20. Call the proper method to change box2's dimension to have a width of 50 and a height of 30. Display the properties of box1 and box2. - Call the proper method to find the smallest intersection of box1 and box2 and store it in reference variable box3. - Calculate and display the area of box3. Hint: call proper methods to get the values of width and height of box3 before calculating the area. Display the properties of box3. 9) Sample output of the program is as follow: Output - 1213 Module2 (run) x run: box1: java.awt. Rectangle [x=10, y=10,width=40,height=30] box2: java.awt.…public class Author2 {3 private String name;4 private int numberOfAwards;5 private boolean guildMember;6 private String[] bestsellers;78 public String Author()9 {10 name = "Grace Random";11 numberOfAwards = 0;12 guildMember = false;13 bestsellers = {"Minority Report", "Ubik", "The Man in the HighCastle"};14 }1516 public void setName(String n)17 {18 name = n;19 }20 public String getName()21 {22 return name;23 }2425 public void winsAPulitzer()26 {27 System.out.println(name + " gave a wonderful speech!");28 }29 } 1. This class includes a constructor that begins on line 8; however, it contains an error. Describe the error. 2. Rewrite the constructor header on line 8 with the error identied in part c of this question corrected. 3. Demonstrate how you might overload the constructor for this class. Write only the header. 4. Write a line of Java code to create an instance (object) of this class. Name it someAuthor. 5. Write a line of code to demonstrate how you would use the someAuthor object…
- public static class Lab2{public static void Main(){int idNum;double payRate, hours, grossPay;string firstName, lastName;// prompt the user to enter employee's first nameConsole.Write("Enter employee's first name => ");firstName = Console.ReadLine();// prompt the user to enter employee's last nameConsole.Write("Enter employee's last name => ");lastName = Console.ReadLine()// prompt the user to enter a six digit employee numberConsole.Write("Enter a six digit employee's ID => ");idNum = Convert.ToInt32(Console.ReadLine());// prompt the user to enter the number of hours employeeworkedConsole.Write("Enter the number of hours employee worked =>");// prompt the user to enter the employee's hourly pay rateconsole.Write("Enter employee's hourly pay rate: ");payRate = Convert.ToDouble(Console.ReadLine());// calculate gross paygrossPay = hours * payRate;// output resultsConsole.WriteLine("Employee {0} {1}, (ID: {2}) earned {3}",firstName, lastName, idNum,…public class DesertEvent { private static int eventCount = 0; private String barCode; private String location; private String eventName; private String eventType; private int quantity; private int capacity; private int seatsTaken; public DesertEvent(String eventName, String eventType) { this(eventName, eventType, 0); calcMaximumSeats(eventType); generateBarCode(); } public DesertEvent(String eventName, String eventType, int capacity) { this.eventName = eventName; this.eventType = eventType; this.capacity = capacity; generateBarCode(); eventCount++; } public String getBarCode() { return barCode; } public String getLocation() { return location; } public String getEventName() { return eventName; } public String getEventType() { return eventType; } public int getQuantity() { return quantity; } public void setQuantity(int quantity) { this.quantity = quantity; } public int getCapacity() { return capacity; } public void setCapacity(int capacity) { this.capacity = capacity;…Here is the class MyBookShelfTester public class MyBookShelfTester {public static void main(String[] args) {MyBookShelf bookShelf = new MyBookShelf(); Book book1 = new Book("Diaspora", "Greg Egan");Book book2 = new Book("What if?", "Randall Munroe");Book book3 = new Book("Foundation", "Isaac Asimov");Book book4 = new Book("Solaris", "Stanislaw Lem");Book book5 = new Book("The Hitchhiker's Guide to the Galaxy", "Douglas Adams"); bookShelf.addCount(book1);bookShelf.addBook(book2);bookShelf.addBook(book3);bookShelf.addBook(book4);bookShelf.addBook(book5); book1.addRating(5);book1.addRating(5);book1.addRating(4);book1.addRating(4); book5.addRating(5);book5.addRating(5);book5.addRating(4); book4.addRating(5);book4.addRating(5); book1.checkOut();book2.checkOut();book3.checkOut();book4.checkOut();book5.checkOut(); book1.returnToLibrary();book2.returnToLibrary();book3.returnToLibrary();book4.returnToLibrary();book5.returnToLibrary(); Book diaspora = bookShelf.getBookByTitle("Diaspora");Book…