Create a class named MyOctagon that contains the following method: /** Prints the area of the octagon. */ public static void octagonArea (double side) Write a test program that reads the side a of an octagon, and calls the above method to print its area. Tips: The formula for computing the area of octagon is: S =. Here are a sample runs:
Q: a method orderFood() for the class Food that simulates ordering food. The method takes an integer as…
A: Python used to answer this question
Q: Add three (3) classes named Quadrilateral, Rectangle, and Square. Rectangle shall inherit from…
A: import java.util.Scanner; class Quadrilateral{ public void showDescription() {…
Q: Write a method called DisplayHorizontalStars(int numberOfStars). This method will output the number…
A: Coded using C#.
Q: Create a class called Hangman with the field n (number of incorrect guesses (int)). • include an…
A: The program is written in Python. check the program screenshot for the correct indentation. Please…
Q: Complete method area in the following class. All it needs is a return statement. class Rectangle:…
A: Code: class Rectangle: def __init__(self, w: float, h: float) -> None: self.width = w…
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: Write an equals method for the Car class given here. Two Cars are equal if their Vehicle…
A: In order to check two objects are equal or not the better way is to override equals method of Object…
Q: PLEASE USE PYTHON PROGRAMMING Create a class called Numbers, which has a single class attribute…
A: class Numbers: MULTIPLIER = 5 # TODO: create a class attribute called MULTIPLIER def…
Q: 1. Create a class named RunQuad. This class shall contain the main method. 2. Add three (3) classes…
A: The program is written in Java. Check the program screenshot for the correct indentation. Please…
Q: Create a class named Employee with a method information. Then take the input of n number of…
A: CODE FOR THE ABOVE QUESTION import java.util.Scanner; import java.io.*; import java.io.file; public…
Q: 5. If you have the following methods in a class, will the code compile? double y, String s) int y,…
A: In the question we have four methods public void drawHex( int x , double y , String s ) public void…
Q: 9. Write a program that includes a void method called showHealthStatus that displays health status…
A: Solution:- import java.util.Scanner; public class BMICalculator { public static int…
Q: True or False? The following code snippet contains a bug. Assume the code is inside of the main…
A: GIVEN: True or False? The following code snippet contains a bug. Assume the code is inside of the…
Q: Write a program that accepts two numbers. Use Scanner class to get the user input. Create 4 classes,…
A: Here I have created 3 different classes named Add, Subtract, and Multiply. In all the three classes…
Q: 2. If you have the following two methods in a class, will the code compile? public int getMileage…
A: The question has been answered in step2
Q: What is the error in the code below? public class Test { public static int calcProfit (int x)…
A: A class method is a method which is bound to the class and not the object of the class.
Q: Create a class namely Circle and do the following: (i) Circle will have the following member…
A: The program is written in java
Q: Write the CheckingAccount class so that the following code generates the output below: class…
A: numberOfAccount is a class level variable which can be accessed by using class name and this gets…
Q: 4. If you have the following two methods in a class, will the code compile? public int getMileage…
A: The question has been answered in step2
Q: 1. If you have the following two methods in a class, will the code compile? public int getMileage…
A: Answer: Option A: No
Q: Exercise #2 Write a method that takes one dimensional array of type Book and returns the average…
A: Actually ,program is an executable software that runs on a computer.
Q: Create a class with name savingaccont.In this class you have to write the static method having name…
A: As no language is mentioned here, C++ has been used to design the code. The code has been given in…
Q: 1. Create a class named RunQuad. This class shall contain the main method. 2. Add three (3) classes…
A:
Q: USING PYTHON Create a class called Hangman with the field n (number of incorrect guesses (int)). ●…
A: Python program to solve the given problem is below.
Q: Part2: Write a class that contains the following two methods: /** Convert from feet to meters */…
A: Given: Write a class that contains the following two methods: /*Convert from feet to meters*/public…
Q: Write the CheckingAccount class so that the following code generates the output below: class…
A: ANSWER : Here I have given a python code with the given function name, please find the code, code…
Q: interface B int a; void methodA(); O no problem the method needs to be public the variable a must be…
A: Interface is very similar to an abstract class where it consists of different methods and members…
Q: ** * This is the utility class to accompany RandomNumberGuesser * It contains static methods to…
A: Below is the answer:
Q: ii. The following is a short snippet of code that simulates rolling a 6-sided dice 100 times. There…
A: Code: import java.util.Random; public class LoadedDice extends Random { public…
Q: PLEASE FOLLOW THE INSTRUCTIONS OF THE CODE VendingMachines.h // what to include class…
A: #include <iostream> using namespace std; int main() { int drink = 0; string ifswitch;…
Q: Given a GVDie object and an integer that represents the number of rolls as parameters complete…
A: Here I have defined the method rollSpecificTimes(). Inside the method, I have created a variable to…
Q: Write a class that contains the following two methods: /** Convert from Celsius to Fahrenheit */…
A: code : - public class Main{ public static double celsiusToFahreheit(double celsius) {…
Q: Given class Triangle, complete the program to read and set the base and height of triangle1 and…
A: Answer in step2
Q: The following code is incomplete, you are required to create an object in the main method to call…
A: Import Java utility In Class A GetValue() is defined with boolean as parameter GetValue() will…
Q: a- Write a method called even ToZero that takes as parameter an integer limit'. The method prints on…
A: Java code: import java.util.Scanner;public class Test { //function to print even number from…
Q: Complete method area in the following class. All it needs is a return statement. 1 class Rectangle:…
A: class Rectangle: width = 0.0 height = 0.0 def __init__(self, w, h): self.width =…
Q: Q2. Write a class with 2 methods. The first method determines if any two sides added together are…
A: here I mention code in Java for calculate triangle area. also check isvalid sides or not.
Q: Q3. Modify the class by adding another method that prompts user for a positive integer. The program…
A: In this question, we are asked to write a java program to reverse the number, explained code below
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: 1- Write a java program as follows: a Write a method called isMultipleOffive that takes an integer…
A: In this program we have to write a java program in which the User need to insert the number which…
Q: 8- Create an instance of the following class and call its methods class Exam( int grade; public:…
A: Note:- Please mention programming language name . This is done in java. With the help of instance…
Q: True or False? The following code snippet contains a bug. Assume the code is inside of the main…
A: GIVEN:
Q: Part-2: In your main class write the following methods: 1. A method named reverse that takes an…
A: Part1: define i1, i2 in main function. For simplicity, I have taken array of i1, i2. Part2:…
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: 1. Create a class StaticMethods. DO NOT add the main method to this class. Type in the method…
A: Kindly Note: All the methods have been put in a single code. public class StaticMethods {…
Q: Write a class that contains the following two methods: /** Convert from feet to meters */ public…
A: Class is a user-defined data type in which it binds the member data and member methods. Declare the…
Q: Add three methods to the Student class that compare two Student objects. One method ( -_eq-- )…
A: Solution: Python code: """ File: student.py Resources to manage a student's name and test scores.…
Q: What is the output of the following code? class example{ private: int a,b; public: example(int m,…
A: Given: #include <iostream>#include <cmath>using namespace std;class example{ private:…
Step by step
Solved in 2 steps with 1 images
- Write a class that contains the following two methods: /** Convert from Celsius to Fahrenheit */ public static double celsiusToFahrenheit(double celsius) /** Convert from Fahrenheit to Celsius */ public static double fahrenheitToCelsius(double fahrenheit) The formula for the conversion is as follows: fahrenheit = (9.0 / 5) * celsius + 32 celsius = (5.0 / 9) * (fahrenheit – 32) Write a test program that invokes these methods to display the following table: NOTE: Celsius starts at 40 and should be converted to Fahrenheit, on the same line Fahrenheit starts at 120 and should be converted to Celsius Do not forget to Introduce your Program to the user with descriptive information. Do not forget to include a block Comment header at the start of your Source Code.1) Through BlueJ, write if the current number of shoppers is greater than or equal to the number leaving then the number of shoppers is decreased by the number leaving. Otherwise, the following error message must be printed and the number of shoppers present must be set to 0. There is an error in the number of shoppers. Use System.out.println to print the message. 2) The class must define a method called leaving that takes a single integer parameter. This represents the number of shoppers leaving the club at a particular point. You may assume that the parameter's value will always be greater than zero and you do not have to check for that. If the current number of clubbers is greater than or equal to the number leaving then the number of clubbers is decreased by the number leaving. Otherwise, the following error message must be printed and the number of clubbers present must be set to 0. There is an error in the number of shoppers. Use System.out.println to print the error message. 3)…Create a class with name savingaccont.In this class you have to write the static method having name CalculteFutureValue which takes three parameters of type double along with return type double.This function should implement the formula given below.The formula, which is known as the future value formula, is:F = P * (1 + i)tThe terms in the formula are as follows: F is the future value of the account after the specified time period. P is the present value of the account. i is the monthly interest rate . t is the number of months . Write Driver class which contains main function that prompts the user to enter the account’s present value, monthly interest rate, and the number of months that the money will be left in the account. The program should pass these values to a function named CalculteFutureValue that returns the future value of the account, after the specified number of months. The program should display the account’s future value.
- 3. Write a class Student having attributes to store the following data: Name, fathers’ Name, department, degree, enrolment, seat number, marks of three subjects. Also write a class to test all methods of Student class. Add the following methods in the above class. • int getTotal() : This methods returns the total of marks • void printTotal() Prints the total marks of Student • float getPercentage() this method calculates the percentage of a student • void printPercentatge() this method prints the percentage of student • char getGrade() this method calculates and returns the grade. • void printGrade() this method prints the grade of a student. • void printInfo() This method prints all information of the student.JAVA PROGRAM Chapter 7. PC #1. Rainfall Class Write a RainFall class that stores the total rainfall for each of 12 months into an array of doubles. The program should have methods that return the following: • the total rainfall for the year • the average monthly rainfall • the month with the most rain • the month with the least rain Demonstrate the class in a complete program. Main class name: RainFall (no package name) NOTE, THE MAIN CLASS NAME needs to be Rainfall as mentioned above AND IT HAS TO PASS ALL THE TEST CASES WHEN I UPLOAD IT TO HYPERGRADE. THANK YOU Enter the rainfall amount for month 1:\n1.2ENTEREnter the rainfall amount for month 2:\n2.3ENTEREnter the rainfall amount for month 3:\n3.4ENTEREnter the rainfall amount for month 4:\n5.1ENTEREnter the rainfall amount for month 5:\n1.7ENTEREnter the rainfall amount for month 6:\n6.5ENTEREnter the rainfall amount for month 7:\n2.5ENTEREnter the rainfall amount for month 8:\n3.3ENTEREnter the…public class BackAccount{public double Balance { set; get; }public void Deposit(double amount){Balance = Balance + amount;} }Transaction FeesTransaction TypeDeposit Withdrawal Check BalanceAmount0.25 % of the deposit amount 0.5 % of the withdrawal amount FreeUsing the code snippet above, complete the bank account functionality by adding Withdraw and CheckBalance methods. In your definition for the Withdraw method, check if the account has sufficient funds before making a withdrawal. Apply transaction fees as per the table above:
- //Todo write test cases for SimpleCalculator Class // No need to implement the actual Calculator class just write Test cases as per TDD. // you need to just write test cases no mocking // test should cover all methods from calculator and all scenarios, so a minimum of 5 test // 1 for add, 1 for subtract, 1 for multiply, 2 for divide (1 for normal division, 1 for division by 0) // make sure all these test cases fail public class CalculatorTest { //Declare variable here private Calculator calculator; //Add before each here //write test cases here }Program62.javaWrite a program that prompts for a full name (first and last) and assigns it to one string. The program then passes the full name to a void method as its sole parameter. The void method should print the first name, on one line, as many times as indicated by the length of the last name. Sample Output (image below) Program64.javaWrite a program that demonstrates method overloading by defining and calling methods that return the area of a triangle, a rectangle, or a square.2. Write a java program which will input an integer value from the user (Use Scanner class). Your program will have mathOper() method in addition to the main() method.The main() method will be responsible for:a. extracting the 1's digit (ones), the 10's digit (tens), and any digits larger than the 10's digit. For instance, if the input is 3562, the 1's digit would be 2, the 10's digit would be 6, and the remaining digits would be 35.b. call the mathOper() method with these 3 values,c. print the results to the screen.The mathOper() method will make the following calculations:a. Multiply the 1's digit by 7, subtract the result by 2 and then divide that by 5.b. Add 3.5 to the 10's digit, multiply the result by 4.3 and then divide that by 2.c. Subtract 5 from the remaining digits, multiply the result by 3, find the remainder after dividing that by 7, and then add 6 to the remainder value.d. Add the 3 values obtained from ‘a’, ‘b’, and ‘c’ operations.e. Return the final value.Sample output…
- Write a method that prints numbers using the following header:public static void printNumbers(int num1, int num2, intnumberPerLine)This method prints the characters between num1 and num2 with the specifiednumbers per line. Write a test program that prints ten characters per line from 1to 100. Numbers are separated by exactly one space.What is the error in the code below? public class Test { public static int calcProfit (int x) { // method body omitted to save space } public static int calcProfit (int y) { // method body omitted to save space } }Complete method area in the following class. All it needs is a return statement. class Rectangle: """ A rectangle with a width and height. """ def __init__(self, w: float, h: float) -> None: """Create a new rectangle of width w and height h. >>> r = Rectangle(1.5, 2.7) >>> r.width 1.5 >>> r.height 2.7 """ self.width = w self.height = h def area(self) -> float: """Return the area of this rectangle. >>> r = Rectangle(10.0, 20.0) >>> r.area() 200.0 """