Write a Java program to create a class named oddeven. Accept an integer value form a user at the keyboard. Create a non static method named “find” and pass the accepted value to this method to check whether the given number is odd or even.
Q: write a java program which Create a Product object: “Laptop”, $799.99• Create a Product object:…
A: Below are the java program and its approach: - Approach: - Creating a class product and declaring…
Q: Write a java code , Create a class named Movie that can be used with your video rental business. The…
A: PROGRAMMING APPROACH: Import a package to get the standard input-output. define the class.…
Q: Write a Java program with the following: A method with name display to display the average time,…
A: Programming instructions: Include necessary header files. Create required variables. Create a…
Q: Write a class in java with the name AgeMessages , which does the following: a. Ask the user to enter…
A: Java program to solve the given problme is below.
Q: Write a complete Java program in a class named Mantra that produces the following output. Remove its…
A: Java is an object-oriented programming language. In Java everything is connected to classes and…
Q: Write a class method to convert inches to centimeters (use double types, and note that 1 inch =…
A:
Q: Write a java program that will check the validity of a password: a. Prompt the user to enter a…
A: We use string.charAt(i) to determine the character in the string at index i. We find the length of…
Q: Write a Java program that takes in three numbers from the user. The program must make use of a…
A: algorithm:- input three numbers . pass it to sum(first,second, third) define sum…
Q: Write a java program that prints the value of the following series for a given X. The user should…
A: The program is implemented in java using structured approach. We have a function sinX which accepts…
Q: Write a program whose inputs are four integers, and whose outputs are the maximum and the minimum of…
A:
Q: Write a program which does the following: 1. Create a class with the main() method. 2. Take a string…
A: import java.util.*; class prog{ static int countNumberOfConsonants(String val){ String…
Q: Write a method in Java called processName that accepts a Scanner for the console as a parameter and…
A: JAVA CODE: //import the Scanner class...import java.util.Scanner; public class Main{ //define the…
Q: Write a complete Java program in a class named TwoRockets that generates the following output. Use…
A: Java program for the given problem is: public class TwoRockets { public static void main(String[]…
Q: va program that will compute the future investment value at a given interest rate for a specified…
A: GIVEN: Create a java program for the above question.
Q: Exercise 2: A. Write static methods: public static double cubeVolume(double h) : h3 public static…
A: The Java OOPS code to do the job described in problem statement is: Part A) Keeping cube, Cylinder…
Q: Create a java program that have a class named Movie that holds a movie name and rating. Provide…
A: public class Movie{ //declaring instance variables private String name; private double…
Q: Write a method in Java named printGPA that calculates a student's grade point average. The user will…
A: Let's solve the given problem using printGPA method in Java programming language. Input: import…
Q: Write a Java program with a class named Introduction that prints: 1. Your name. 2. A blank line. 3.…
A: Java programming: Java is a class-based, object-oriented general-purpose programming language. The…
Q: Write a separate class BookDemo with a main() method that creates a Book object titled “Developing…
A: class Book{ private String name; private String author; private double price;…
Q: Write a class in java with the name AgeMessages , which does the following:a. Ask the user to enter…
A: The algorithm for the program would be as below:Declare one float variable for accepting user…
Q: What will be the output of the following Java code? 1. class access 2. public int x; 3. 4. private…
A: Let's take a look into access modifiers in java and types of errors: The access modifiers in Java…
Q: Write a java program to save information of 5 students in a class called "students" use matrix of…
A: Input : Input name, age, and email of 5 students. Store information in the matrix. Output : Show…
Q: Write a Java program to create a class in your name. Accept an integer value as radius from a user…
A: Step-1: Start Step-2: Declare a variable radius and take input from user Step-3: Create a function…
Q: Write a Java class called Power. This class defines a method called power() which takes as…
A: Algorithm: Start Create a class named Power Inside the class, implement a method named power()…
Q: Write a program which does the following: 1. Create a class with the main() method. 2. Take a string…
A: Code: import java.util.Scanner;public class Main { public static void main(String args[]){…
Q: Write a program in java . Create a class names “A” with a method to print “ method of class A”.
A: public class A { //creating a class name A public void…
Q: Write a Java program to create a class called Shape, from which we will loop 2 objects into one…
A: Write a Java program to create a class called Shape, from which we will loop 2 objects into one…
Q: Write a java program (class) named “TelevisionDemo”, that will use a class, “Television” that will…
A: The main objective of the java program is to create two classes Television.java…
Q: Write a java program that has the following methods: • A method called printSquares that has an…
A: Hi there, Please find your solution below, I hope you would find my solution useful and helpful.…
Q: Write a java class called House with the following two private attributes, and three methods:…
A: The classes House and HouseMap are given below and their formatted image version: public class…
Q: Exercise 3: A. Write static methods: public static double sphereVolume(double r) :ar public static…
A: Geometry.java public class Geometry{ public static double sphereVolume(double r) { return…
Q: Write a class in java with the name AgeMessages, which does the following: a. Ask the user to enter…
A: INTRODUCTION: In the given code statement, we are asked to create one java class and naming it as…
Q: Write the appropriate method headings using the provided method names for ead of the following…
A: AREA of Circle Import the scanner class Create a class Area with data member area and member…
Q: Create another class DayProg and write the main() method to display the following: Today is…
A: As the language is not specified answer written in python to deal with date and time we need to…
Q: Write a Java program with a class named Introduction that prints: 1. Your name. 2. A blank line. 3.…
A: Solution : Here i am providing you the program code along with the output. Program Code : public…
Q: Write static methods: • public static double cubeVolume(double h) : h! • public static double…
A: Here are the 2 classes ======================================================================…
Q: Write a simple Java program to calculate the average daily temperature from the given daily…
A: The below-given java program will obey the following rubrics: Importing necessary header files.…
Q: Write a Java programme to compute students' marks. A Student has fields for an ID number, the number…
A: Program:class Student{ //Q.4.1 setting the all fields private int ID; private int credit;…
Q: Create a Java program that will have the following methods in another class. showHigh – will det…
A: Please find the java program for the above question.
Q: Write a program in Java using classes, methods, and objects to do the following tasks.…
A: Lets see the solution.
Q: Write a Java program that prompt user to input 10 students in a class. Then, prompt user to input…
A: The code given here is
Q: Write a program which does the following: 1. Create a class with the main() method. 2. Take a string…
A: Java Code: import java.util.*; // Main classpublic class Main{ // Method that counts the number…
Q: Build a java program that checks on a user who tries to change current password by asking some…
A: Java used to answer this question
Q: Define a method printDate, with int parameters year and day, and string parameter month, that prints…
A: Syntax: returnType methodName ( [ parameterList ] ) { // Method-body } returnType -> It is…
Q: The following is in Java: public class MyClass { private int x; private double y;…
A: Defined the given Java code
Q: Write a JAVA program that converts a number entered in Roman numerals to decimal. Your program…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: 5. Write a method lastNameFirst that takes a string containing a name such as "Harry Smith" or "Mary…
A: A method that will print the first name and last name in reverse order that is last name, first…
Q: Exercise 2: A. Write static methods: public static double cubeVolume(double h) : h public static…
A: Below is the required Java program: - A. Program: - //Import the package import java.util.Scanner;…
Q: Write a method triangleArea() which a receives as input two integers representing the base length…
A: NOTE:- As the language is not mentioned. So, the program is done using C language. CODE:- #include…
Q: Write a Java method that takes a variable of type String and returns a boolean value. The method…
A: *Note: Save the code in a file named "Main.java" otherwise it will not compile. This is because,…
Step by step
Solved in 2 steps
- Write a Java program to create a class named Exponent. Accept an integer value from a user at the keyboard, and in turn passes the value to a method that squares the number (multiplies it by itself). The main () method displays the calculated value.use the file Dining.java which is provided below and Complete the calcTip() method as described in the comments. Then add a new method called splitBill() which receives as input an integer value, representing the number of diners, and returns each person's equal share of the bill.Write a class in java with the name AgeMessages , which does the following:a. Ask the user to enter age using a Scannerb. If the age is less than 13, print: “too young to create a Facebook account”c. If the age is less than 16, print: “too young to get a driver's license”d. If the age is less than 18, print: “too young to get a tattoo”e. If the age is less than 21, print: “too young to drink alcohol”f. If the age is less than 35, print: “too young to run for President of the U.S.” and on nextline print: “(How sad!)”g. If the age is greater and equal to 35, print: “able to do anything” and on next line print:“(How happy!)”Tips Use only an if statementCopy and paste your code Screen shot the console with user input of 2 Screen shot the console with user input of 18 Screen shot the console with user input of 91
- Create a method in java that takes a value and indicates whether it is positive or negative by a return a Boolean value. Declared as: boolean is positive (float a) (with a screenshot of the code please)Write a Java program that contains two static methods:Method 1 called FtoC( ) that converts a Fahrenheit degree to its equivalent Celsius degree using the formula C=5/9(F-32) where F is Fahrenheit degree and C represents Celsius degree. For example: F=70 is C=5/9(70-32)=21.1. Your program asks the user to enter temperature in Fahrenheit degree and then displays its equivalent in Celsius.Write a Java program that randomly generates a three-digit lottery number and prompts the user to enter a three-digit number. Each digit in the number is in the range between 0 to 9 with both 0 and 9 possible numbers. Write a method named getPrize() to determine which prize the user wins following the rules shown below. The method getPrize() should return an integer representing which prize was won such as 1 for first, 2 for second, etc. It should return -1 if no prize was won.
- 4. Write a java program that will check the validity of a password:a. Prompt the user to enter a password (a string, use Scanner class to read the password)b. Check the validity of the password by calling a method, named passValidity()c. Return an appropriate message (i.e. password is valid or invalid) to the main() method. The main() method will print the message.The passValidity() method will:a. take the password as the input parameter,b. check the validity as per the following rule:• the password string must have at least eight characters • the password must have at least one alphabet • the password must contain at least one digit• the password must contain at least one special character from @, #, $, and &c. return an appropriate message to the main() method.Sample output (assuming the input is ab459#de0):The password is validSample output (assuming the input is abcd#de&ui):The password is invalidWrite a java method called alarm that prints the string "Alarm!" multiple times on separatelines. The method should accept an integer parameter that specifies how many times thestring is printed. Print an error message if the parameter is less than 1.write a Java program that will compute the future investment value at a given interest rate for a specified number of years. The java program should have a minimum of two classes. 3.1.1 classA • The main method (starting point) (5) • The object of classb (5) • Should also call the void method named futureInvestmentValue (double investment Amount, double monthlyInterestRate, int years) (15) 3.1.2 classB • A get method named count_words(String str) (15) Expected Output: Input the investment amount: 28000 Input the rate of interest: 7 Input number of years: 6 Years Future Value 1 30024.12 2 32194.57 3 34521.92 4 37017.51 5 39693.51 6 42562.95
- The following Java code is poorly structured. Rewrite it so that it has a better structure and avoids redundancy. To help eliminate redundancy, convert the code into a method named spending that accepts two parameters: a Scanner for the console, and a String for a single person's name, and prints the appropriate information about that person's bills. Your method could be called twice (once for John and once for Jane) to replicate the original code's behavior. public void spending(Scanner console,String name) { System.out.print("How much will " + name + " be spending?"); double amount = console.nextDouble(); System.out.println(); int numBills = (int) (amount / 20.0); if (numBills * 20.0 < amount) { numBills++; } System.out.println(name + " needs " + numBills + " bills"); } The code above is all I was given to work with, which is why I'm a bit confused and need help. Thank you.Write a Java program with the following: A method with name display to display the average time, the longest time, and theshortest time taken to travel from home to MEC during that week of that studentWrite a declaration for a java class named BallpointPen, using the variable names and methodnames mentioned below. Fill in the bodies of each method as well. The state of a ball-point pen with a retractable point can be represented by two values:Is the point of the pen exposed?How much ink remains in the pen?Operations on a pen include:Press the button at the end of the pen.Move the pen with the point held against a sheet of paper.Replace the pen’s cartridge.Determine how much ink remains in the pen.