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 definition for a method with the following heading. Themethod is to be added to the…
A: Since the language is not mentioned, I have completed it using Java.
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: In this challenge, you need to implement a method which squares passing variables and return their…
A: Algorithm for the function squareSum Given input = num1,num2,num3 as three input numbers 0.Start…
Q: 11. Implement a class to represent a playing card. Your class should have the following methods:…
A:
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: 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: Write a class Student having attributes to store the following data: Name, fathers’ Name,…
A: public class Tester { //declaring a class public static void main(String[] args) { //declaring…
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: Consider the following method header, and then write a call to this method that passes the integer…
A:
Q: Class: DoubleMethod Write a method using the header below public static double…
A: Here in this program, I have completed the method which will take a prompt as an argument and return…
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: 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: Write a method printMultiples that takes two integers x and y as parameters, and prints the numbers…
A: import java.util.Scanner; public class Main{ public static void printMultiplies(int x, int y){…
Q: 1. Create a class named RunQuad. This class shall contain the main method. 2. Add three (3) classes…
A:
Q: 1. For this part you need to use the floor method and max methods in the Match class. Moreover,…
A: Here I have declared 2 variables min and max to store the range of numbers, and then I have used…
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: 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: 3) Write a method that computes the speeding penalties of cars. Given as inputs the speed of the…
A: The code has been written in Java as no programming language has been mentioned.
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: Write a program that uses separate class-level methods to print a table of integers and the digits…
A: The several class-level methods are that kind of methods that does not use the class object. These…
Q: 1) Implement the class Image: The height, width and size data fields should be positive. The…
A: Java code import java.util.Date; public class Image { //class with all the variables withdefault…
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: 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: 1. For each call of the method below, display the value that is returned public int retVal(int a,…
A: Explanation: In case of option d, if we pass x to a and y to b and if x takes 20, then y should…
Q: 53. Write a class with two instance variables, representing an old password and a new password.…
A: Since no programming language is mentioned, I am using java Code: class Client{ private String…
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: 1. Write down a method that will take an integer as a parameter and will return 1 if the integer is…
A: Program description: n is the user input integer variable that is used to store the upper limit of…
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: 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: 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: Program62.java Write a program that prompts for a full name (first and last) and assigns it to one…
A: As per guidelines we are supposed to answer only one question. Kindly repost other questions as…
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 3 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 } }1. For each call of the method below, display the value that is returned public int retVal(int a, int b) { int c; if (a > b) { c = a; } else if (b % a == 0) { c = b; } else { c = b + (a - (b % a)); } return c; } Read the following arguments from the keyboard and pass them to retVal()Arguments passed a. retVal(4, 2) b. retVal(5, 4) c. retVal(5, 13) d. retVal(x, y) e. retVal(m, n) Output a. 4 b. 5 c. 15 d. 20 e. 8 For d and e what values are passed to produce 20 and 8?