public static int myMethod (int testValue){ final int TOP_BOUND = // ... what goes here? final int BOTTOM_BOUND = // hhhhmmmm..... here? int myReturnedInt = e; // what goes here? { // and here? // what goes here? { // and here? // what goes here? { // and here? return myReturnedInt;
Q: Exercise 6 - Loaded Coin Simulation Make a new class in the Lab2 project called LoadedCoinSimthat…
A: Note: Answering in python as no language is mentioned. Input : Head probability Number of…
Q: public class TestBloodData { public static void main(String[] args) { BloodData b1 = new…
A: The question has been solved step2:
Q: Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A,B,C,D,E" is…
A: Both of these questions from the inheritance part of the java. The second question is giving the…
Q: Java --- Please help me understand further the code below. Thank you!| --- Circle.java public class…
A: ALGORITHM: Step 1: Create an interface Shape Step 2: In that create 4 classes circle, rectangle,…
Q: The APCalendar class contains methods used to calculate information about a calendar. You will write…
A: Code:-
Q: Exercise 6 - Loaded Coin Simulation Make a new class in the Lab2 project called LoadedCoinSimthat…
A: class LoadedCoinSim { private String sideUp; /** * Default constructor */…
Q: Class RightTriangle Represents a right triangle by the length of each of its two legs Includes the…
A: Program code: //import the required packagesimport java.util.TreeMap;//define the class…
Q: public class MovieRatings extends ConsoleProgram { public void run() { double movierRating =…
A: public class MovieRatings extends ConsoleProgram { public void run() { double…
Q: Below Apex Method and also show the code Coverage Output Here is the Apex code: - public with…
A: Below is the detailed solution to the given problem statement:
Q: The LocalDate class includes an instance method named lengthOfMonth() that returns the number of…
A: A required program is as follows, File name: "DaysTilNextMonth.java" //Import a class LocalDate from…
Q: A string of ( {[]}) is given and you have to check this valid parenthesis. Means if a braces is…
A: write a java program to check the valid parenthesis, create a separate class named solution, and…
Q: Using Java Eclipse IDE do the following program. Programming exercise similar to 9.1, Change…
A: Programming instructions: First, create a class “Square” and then declare two variables width and…
Q: Design the Java classes named Shape, Rectengle end Point by taking into account the following UML…
A: Here, we have to write java code for the above program. I have implemented the code to Point, Shape,…
Q: How should the code be fixed? public class MidtermProblems { // Main driver method public…
A: There are multiple error, here is the explanation.
Q: public class output{ public static int find (int a1, int a2) { if(a1==0) return(a1+1); else if(a1>0…
A: There is a class output in which two method are there find and main. Find method is recursively…
Q: 1. BankAccount with the methods deposit(self, amount), withdraw(self, amount), and…
A: The ask is to write a python program simulating a bank account and having the following: - a…
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: What will be printed? public class Test3 { public static void main(String[] args) boolean…
A: Basic Boolean Logic True && True = True False && False = False True &&…
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: in java A class Book is designed to model a book written by one author. It contains: Four private…
A: //Driver code import java.util.*; public class Main { public static void main(String[] args) {…
Q: Eclipise Exercise 1: Write a Java application that simulates a test. The test contains at least…
A: We can use OOPS based approach to solve the problem:
Q: public class BackAccount { public double Balance { set; get; } public void Deposit(double amount) {…
A: Using code snippet above complete the bank account functionality..
Q: a program using Java NetBeans (Console application). With the following enum class: public enum Day…
A: These programs can be asked from control statements, array, string, oops etc. Java basic programs…
Q: Write the Apex Test Class for the Below Apex Method and also show the code Coverage Output Here is…
A: Required: Apex(Salesforce) Write the Apex Test Class for the Below Apex Methodand also show the…
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: Math: pentagonal numbers) A pentagonal number is defined as n(3n-1)/2 , for n = 1,2, . . ., and so…
A: Pentagon Class: Pentagon Class contains calcPentagonalNumber() definition which returns pentagonal…
Q: Object: Square States: side Behaviors: computeArea(), computePerimeter() Object: RightTriangle…
A: Code: class Square{ double sides; public Square(double sides) { this.sides = sides; } public void…
Q: Write a Rectangle class. Its constructor should accept length and width as a parameter. It should…
A: Answer has been explained below:-
Q: ClockPane.java, to add the animationinto this class and add two methods start() and stop() to start…
A: Program Plan: Import the necessary libraries Present in javafx and util Classes. Create two classes…
Q: Create a class named Player with a default name as "player", a default level as 0, and a default…
A: Required: Create an instance method in the Player class called attack that takes another player as a…
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: ******* In java ***** create a class , and objects for the following exercise 1- for car car…
A: Objective: This program implements the Car and Cellphone classes with specified attributes and…
Q: Java program Make a class Employee with a name and salary. Make a class Manager inherit from…
A: According to the Question below the Solution: Output:
Q: public class ScenarioAnalysis { // Instance variables privateVehicle[] vehicles; // all vehicless…
A: Greenhouse gases (GHGs) warm the Earth by absorbing energy and slowing the rate at which the energy…
Q: v) Write a public instance method addProgrammeItem() that takes a Music argument representing a…
A: Program Instrcution The function add accepts an object of the class Fraction ass a parameter. A…
Q: //Todo write test cases for SimpleCalculator Class // No need to implement the actual Calculator…
A: Program :- import java.util.Scanner;class Main{ public static void main(String[] args) { char…
Q: Make a class that represents an average of test scores. Make the class take an unlimited number of…
A: public class TestScore { //declaring class variables String name; double totalScore; int…
Q: Design a class to store the following information about computer scientists ⦁ Name ⦁ Research…
A: Computer Science computer science, the study of computers and computing, including their theoretical…
Q: Design a class Parallelogram that contains two private data members: - double length, - double…
A: // C++ program to demonstrate implementation // of Inheritance #include <bits/stdc++.h> using…
Q: Support computing sales tax in the CashRegister class. The tax rate should be supplied when…
A: Note: you have not provided CashRegisterTester.java class file. so, we cannot provide compiled code…
Q: Write all the code within the main method in the TestTruck class below. Implement the following…
A: import java.lang.IllegalArgumentException; public class TestTruck { public static void…
Q: Write Unit Test Methods for the code snippets below: package InventoryManagement; /** * AddCommand…
A: Unit test method is a framework for Java programming Language. It is ,used to test the functionality…
Q: Please help me with these errors in java. Errors below public class Student { //student related…
A: Modified code: import java.util.Scanner;import java.sql.*; class Student { String studName;…
Q: public class DateFashion /** Write the method dateFashion(). You and your date are trying to get a…
A: Program description: java program that DateFashionDriver.java that demonstrates the class…
Q: in java please. Create a method from a client perspective that determines if a bag is a set or…
A: ALGORITHM:- 1. Create a hashmap to store each item in wordBag and their count. 2. Traverse through…
Q: * This class describes a tweet. A tweet has a message in it, a unique ID, * a count of the number of…
A: EXPLANATION: - The Tweet class comprises instance variables of the following instance variables: -…
Integer value passed to the method MUST not go above 99 or below -100
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
- [java program] public class ScenarioAnalysis { // Instance variables privateVehicle[] vehicles; // all vehicless being analyzed privatedoublegasPrice; // price of one gallon of gas in dollars privatedoubleelectricityPrice; // price of 1 kWh in cents of a dollar, c$/kWh publicScenarioAnalysis ( doublegasPrice, doubleelectricityPrice ) { this.gasPrice = gasPrice; this.electricityPrice = electricityPrice; } /* * Updates the price of gas * Call computeCO2EmissionsAndCost() whenever there is an update on gas prices */ publicvoidsetGasPrice ( doublegasPrice ) { this.gasPrice = gasPrice; computeCO2EmissionsAndCost(); } /* * Returns the gas price */ publicdoublegetGasPrice () { returngasPrice; } /* * Updates the price of electricity * Call computeCO2EmissionsAndCost() whenever there is an update on electricity prices */ publicvoidsetElectricityPrice ( doubleelectricityPrice ) { this.electricityPrice = electricityPrice; } /* * Returns electricity price */ publicdoublegetElectricityPrice…Computer Science Questionpublic class NumbersDemo { public static void displayTwiceTheNumber(int number){ System.out.println(number + "" + number); } public static void displayNumberPlusFive(int number){ System.out.println(number+5); } public static void displayNumberSquared(int number) { System.out.println(number*number); }
- public class DebugBox { privateint width; privateint length; privateint height; publicDebugBox() { length = 1; width = 1; height = 1; } publicDebugBox(intwidth,intlength,intheight) { width = width; length = length; height = height; } publicvoidshowData() { System.out.println("Width: " + width + "Length: " + length + "Height: "+ height); } publicdoublegetVolume() { double vol = length * width * height; return vol; } } // This class uses a DebugBox class to instantiate two Box objects public class DebugFour3 { publicstaticvoidmain(Stringargs[]) { int width =12, length = 10, height = 8; DebugBox box1 =newDebugBox(); DebugBox box2 =newDebugBox(width, length, height); System.out.println("The dimensions of the first box are"); box1.showData(); System.out.print("The volume of the first box is "); showVolume(box1); System.out.println("The dimensions of the second box are"); box2.showData(); System.out.print("The volume of the second box is "); showVolume(box2); }…Java class Main { publicstaticvoid main(String[] args) { // Coin myPenny = new Coin(CoinType.PENNY); // Coin myNickel = new Coin(CoinType.NICKEL); // Coin myDime = new Coin(CoinType.DIME); // Coin myQuarter = new Coin(CoinType.QUARTER); // Coin myHalfDollar = new Coin(CoinType.HALF_DOLLAR); // Coin myDollar = new Coin(CoinType.DOLLAR); // System.out.println(printValue(myPenny)); // System.out.println(printValue(myNickel)); // System.out.println(printValue(myDime)); // System.out.println(printValue(myQuarter)); // System.out.println(printValue(myHalfDollar)); // System.out.println(printValue(myDollar)); } publicstatic String printValue(Coin c){ String result = ""; // result = String.format("The value of a %s is $%.2f", c.getName(), c.getValue()); return result; } }// Some circle statistics public class DebugFour2 { publicstaticvoidmain(Stringargs[]) { double radius =12.6; System.out.println("Circle statistics"); double area = java.Math.PI * radius * radius; System.out.println("area is " + area); double diameter =2- radius; System.out.println("diameter is + diameter); } }
- Complete the missing line of code: public class Rectangle { private int width; private int height; public Rectangle( this.width = width3B %3D this.height = height; %3DClass Quiz public Quiz (int quesList, int quesMissed) {quesList = this.quesList;quesMissed = this.quesMissed;} private void calculate(){// get the point worth of each question and calculate final scorepointsPerQues = (100/quesList);scoreQuiz = quesList - quesMissed;} Class PassFailQuiz public PassFailQuiz (int quesList, int quesMissed, int scoreQuiz) { super(quesList, quesMissed);} How do I move scoreQuiz from private void calculate() to equal the third constructor value in PassFailQuiz?int getUpperScore(){ int upperScore = 0; for(int i = ONES; i <= SIXES; i++){ upperScore += score[i]; } return upperScore + getBonusScore(); } //Returns the score of the upper part of the board int getLowerScore(){ int lowerScore = 0; for(int i = THREE_OF_KIND; i <= YAHTZEE; i++){ lowerScore += score[i]; } return lowerScore; } //Returns the bonus points int getBonusScore(){ const int UPPER_SCORES_THRESHOLD = 63; const int BONUS_POINTS = 35; if(getUpperScore() >= UPPER_SCORES_THRESHOLD){ return BONUS_POINTS; } return 0; } //Returns the total score int getTotalScore(){ return getUpperScore() + getLowerScore(); } Test 10: Check upper board and having bonus correctly (0/3) failed
- 3 public class ShippingCalculator { public static void main(StringO args) { new Scanner(System.in); 1 st passed 5 Scanner scnr int shipWeightPounds; int shipCostCents = 0; final int FLAT_FEE_CENTS = 75; 7 Altasts passed 8 10 final int CENTS_PER_POUND = 25; System.out.print("Enter shipping weight: "); shipWeightPounds = scnr.nextInt(); shipCostCents = FLAT_FEE_CENTS + shipWeightPounds * CENTS_PER_POUND; 11 12 13 14 15 16 17 System.out.println("Weight(lb): " + shipWeightPounds); 19 Suctom Aut nnin+1nr"Elnt foofconte): ELAT CCE CETS): Run X Testing shipWeightPounds = 10 Output differs. See highlights below. Special character legend Enter shipping weight: Weight (lb) : 10 Flat fee (cents): 75 Your output Cents per pound: 25 Shipping cost (cents) : 325 Weight (1b) : 10 Flat fee (cents): 75 Expected output Cents per pound: 25 Shipping cost (cents): 325 X Testing shipWeightPounds = 22D Graphics You have learned 2D graphics from DrawPanel.java (see code below) // DrawPanel.java // Using drawLine to connect the corners of a panel. import java.awt.Graphics; import javax.swing.JPanel; public class DrawPanel extends JPanel { // draws an X from the corners of the panel public void paintComponent( Graphics g) { // call paintComponent to ensure the panel displays correctly super.paintComponent( g ); int width = getWidth(); // total width int height = getHeight(); // total height // draw a line from the upper-left to the lower-right g.drawLine(0, 0, width, height); // draw a line from the lower-left to the upper-right g.drawLine(0, height, width, 0); } // end method paintComponent } // end class DrawPanel 3. Write a Java program that does all of the following 3 actions. a. draws a line from (20, 50) to (50, x) of length 50. Compute the value x first. b. draws a rectangle with (20, 50) as the lower left corner, height 10 and width 100. c. fills a rectangle with (20, 50) as…9 public class PictureViewer 10{ public static void main(String[] args) 11 12 // Step 2: Fix the syntax errors and submit it to Codecheck to pass the test. // Note: Do not add or remove any statements 13 // 14 15 // Do not change the semantics of each statement Do not add or remove any variables Do not add or remove any objects Magic numbers are allowed 16 17 18 // 19 // 20 // Create an object of Picture by loading an image Picture pic = Picture("starry_night.png"); 21 22 23 // Display the width and height System.out.println("Width : " + pic.getWidth()); System.out.println("Height: 24 25 + pic.getHeight()); %3D 26 27 // Increase the width by 50 on both sides and // increase the height by 40 on both sides. // Must use dw and dh when calling method grow(). int dw, dh = 40; pic.grow(dw, dh); 28 29 30 31 32 33 // Display the width and height System.out.println("Width : System.out.println("Height: 34 + pic.getWidth()); + pic.getHeight()); 35 36 37 // Draw the picture draw(); 38 39 40 //…