Complete the following piece of java code, so that it could convert date to Julian number and Julian number to date. public class JulianNumber { public static int toJulianNumber( int day, int month, int year ); // returns an array of integers for day, month, and year public static int[] fromJulianNumber( int julianNumber ); }
Q: in java create a class shopping mall. It has Items with name, manufacturer and price. Provide…
A: public class Tester{ public static void main(String[] args) { //create instances of items Item…
Q: Write a JAVA program to create an array of objects of a class student. The class should have field…
A: Java is a programming language. It contains extensive libraries (package). It can be used to create…
Q: Write a function inside ProblemSolution class whose return type is void, accepts an array and the…
A: Solution :
Q: Implement all the classes. The formula for calculating salary for each class is shown below: For…
A: Below is the code in java and sample output:
Q: Write a method that returns the percentage of elements greater or equal to 90 in an array of…
A: public static void main(String args[]) { int a[] = {}; System.out.println(calcPercentage(a));…
Q: Write a program which does the following: 1. Create a class with the main() method. 2. Take a string…
A: note:- length() and indexOf() both returns indexes in numeric, you must have to use charAt() to…
Q: FOR JAVA Write a Java class named Book, which has a name, an author and a pub- lisher. This class…
A: Algorithm: Start Create a class Book with data members name,author,publisher and static array…
Q: java Finish the method called printUniqueNumbers() that will take anint [] and print out all of the…
A: 1) Below is java program that defines function printUniqueNumbers which print all unique number in…
Q: Write a RainFall class that stores the total rainfall for each of 12 months into an array of double…
A: import java.text.*; import javax.swing.*; import java.util.Scanner; class RainFall { static…
Q: Write in java 1. Write a program that calls these two methods as described below a. A void method…
A: The main objective of the java program,Driver.java is to create two static methods pattern and…
Q: 1. Rainfall Class Write a RainFall class that stores the total rainfall for each of 12 months into…
A: The program should have methods that return the following: The total rainfall for the year The…
Q: Implement getEvens method Method Details getEvens public static int getEvens(int[] array, int[]…
A: The method getEvens takes two integer array as parameters. The first parameter in the input array…
Q: Consider the class Array below that encapsulates an array of integers. Add a member method…
A: In this problem statement need to find the smallest value in the array. Array class created…
Q: Write a java program to complete the following parts: Part-1: Create a class Car and perform the…
A: According to the information given:- We have to follow the instruction mentioned to implement in…
Q: Implement the following class and test its methods: Fraction - numerator. int - denominator. int +…
A: Created 2 versions of the program. 1st version takes input from the user and 2nd version doesn't…
Q: Using java Hamburger Class Write a Hamburger class with the following six attributes: • bun - the…
A: Actually, in the program given attributes are: Hamburger class with the following six attributes:•…
Q: Write a method that returns the index of the smallest element in an array of doubles. The method…
A: As given, I need to write a Java program having a method that should receive an array for formal…
Q: Suppose that we have the following class: 1 class Book{ 2 private: 3 int id; 4 char name [20]; 5…
A: I have added commands in both codes. I have written a separate code for each question. Also in both…
Q: Consider the following class declaration: class Student { public: int * grades; Student (int n) { //…
A: b. deleting s1 also deletes s2
Q: This question is in Java Filter out each word with an odd number of characters public class…
A: Java program to filter out each word with odd number of character from Array list of string
Q: Language: Java Write a class encapsulating the concept of daily temperatures for a week with a…
A: Actually, java is a object oriented language. using objects only implement the applications in java.…
Q: 3) Coding below shows an example of a class that defines a makeRange() method. makeRange() takes two…
A: According to the Question below the Solution: Java Code: public class RangeClass{ int[]…
Q: fill in the table to trace the values as they are passed from main and changed in the method.
A: Giving Answer for only (a) part Given Program int [] array = {1,2,3,4,5}; int x = 12; int y =…
Q: Implement the following class and test its methods: Fraction |- numerator. int - denominator. int +…
A: Code: Fraction class import java.util.Scanner; class Fraction{ private int numerator; private…
Q: Write a Java method called average which takes an array as parameter and returns the average value.…
A: // Main classpublic class Main{ // Method to find the average of number public static double…
Q: Write a Java class named Book, which has a name, an author and a pub- lisher. This class must also…
A: public class Main{ public static void main(String[] args) { //create 2 books Book b1=new…
Q: Write a program named GradeStats.java then implement the following method: public static int[]…
A: Start Initialize array Find maximum Find minimum Find sum and then average Find number of grades…
Q: FOR JAVA, PLEASE WRITE THE CODE OF THIS QUESTION FOR JAVA Write a static method histogram() that…
A: The java code is
Q: Read the quistion entirely before ansewring the code should compile and run Create a java class…
A: import java.util.Scanner;import java.util.*;import java.lang.*;public class Question2{public void…
Q: 2. Implement the class billBook using the above UML: a. Write the constructor that takes as…
A: Here I written Java code for given problem. I hope you like it. with implements of billBook also…
Q: a)Implement all the classes. The formula for calculating salary for each class is shown below: For…
A: Inheritance is the feature of the object oriented programming language. Java supports inheritance.…
Q: 1. write a static method that receive as parameter an array of type student and print the names of…
A: This is a multiple type question, so according to the guidelines, the first question has been…
Q: 1. Giving the following Java program representing the class student, complete the missing code. a.…
A: Here, I have to write a java program for the given class Student and complete the parts given.
Q: Write a code in JAVA for storing information of Employee using array. Employee attributes for…
A: Program approach:- Then creating an array class to store the employee's objects. Using add method…
Q: write the code in java. Write the class Student having attributes name (String), age (int) and cgpa…
A: Given: write the code in java. Write the class Student having attributes name (String), age (int)…
Q: Finish the method called printUniqueNumbers() that will take anint [] and print out all of the…
A: So, first and foremost, we'll learn what an array is and how to define one in Java. Later, we'll…
Q: Needs to be written in java: Write a program with a main() method that asks the user to input an…
A: Definition: Method: It is a particular block of the code that is used for running only when that is…
Q: Without using any pre-defined method. Don't copy from internet Two array is given and you check…
A: Requirements:- Without using any pre-defined method. Don't copy from the internet Two arrays are…
Q: Define a static void method, which receives as an parameter an array of salaries (of type double)…
A: Step 1:- Program Approach:- 1.Use the user-defined function whose name is converted (float [] array)…
Q: Step 1: Import Java classes Arrays, Random, and Scanner /** * A class to generate a random int array…
A: The exception, InputMismatchException is a java in-built exception class and it is in the java. util…
Q: Home Task: 1. Implement the following class and test its methods: Fraction - numerator: int -…
A: Code In Java:…
Q: Explain the following Java Polymorphism code in details. class Shape { public double getArea() {…
A: Lets see the solution.
Q: Write two Java classes: Student and Main as follow: Class Student: A. Create three private…
A: (1)First we need to define a Student class with the attributes Name, ID and Specialization (2)In…
Q: IN JAVA Given an array of numbers, return whether it is possible to make the number 7 by adding any…
A: Ask: Determine and write a Java program to validate if sum of 3 numbers in the number Array is 7…
Q: Write a program that asks the user to input two integers a and b. Then create an array that has all…
A: public class Tester{ public static void main(String[] args){ int arr[]; //declare an…
Complete the following piece of java code, so that it could convert date to Julian number and Julian number to date.
public class JulianNumber
{
public static int toJulianNumber( int day, int month, int year );
// returns an array of integers for day, month, and year
public static int[] fromJulianNumber( int julianNumber );
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
- Create the Median class that has the method calculateMedian that calculates the median of the integers passed to the method. Use method overloading so that this method can accept anywhere from two to five parameters. CODE: import java.util.Arrays; //add class definitions below this line //add class definitions above this line public class Exercise4 { public static void main(String[] args) { //add code below this line //add code above this line }}Java: Design the class Circle that can store the radius and the center of the circle based on the class Point we talked in the class. You should be able to perform the usual operation on a circle, such as setting radius, printing the radius, calculating and printing the area and circumference, and carrying out the usual operations on the center. Here is the code: public class Point {public static void main(String[] args) { } protected double x, y; // coordinates of the Point //Default constructorpublic Point(){setPoint( 0, 0 );} //Constructor with parameterspublic Point(double xValue, double yValue ){setPoint(xValue, yValue );} // set x and y coordinates of Pointpublic void setPoint(double xValue, double yValue ){x = xValue;y = yValue;} // get x coordinatepublic double getX(){return x;} // get y coordinatepublic double getY(){return y;} // convert point into String representationpublic String toString(){return "[" + String.format("%.2f", x)+ ", " + String.format("%.2f", y) + "]";}…In Java Write a RainFall class that stores the total rainfall for each of 12 months into anarray of doubles. The program should have methods that return the following: Total rainfall for the year, The average monthly rainfall The month with the most rain The month with the least rainThe program should not accept negative numbers for monthly rainfall figures.You may use the following main function to test the methods:public static void main(String[] args) { // Array with this year's rainfall data double[] thisYear = {1.6, 2.1, 1.7, 3.5, 2.6, 3.7, 3.9, 2.6, 2.9, 4.3, 2.4, 3.7 }; int high; // To hold the month with the highest amount int low; // To hold the month with the lowest amount // Display the total rainfall. System.out.println("The total rainfall for this year is " + getTotalRainFall(thisYear)); // Display the average rainfall. System.out.println("The average rainfall for this year is " + getAverageRainFall(thisYear)); // Get and display the month with the highest rainfall.…
- Method Overloading is a feature that allows a class to have two or more methods having same name, if their argument lists are different. Argument lists could differ in: 1. Number of parameters. 2. Data type of parameters. 3. Sequence of Data type of parameters. Write different version of method sum() that display the sum of the values received as parameter according to the following main method content: public static void main(String[] args) { sum ( 10, 10 ); sum ( 10, 10, 10 ); sum ( 10.0, 10.0 ); sum ( 10, 10.0 ); sum ( 10.0, 10); } You have to define five functions with the specified types. Then, demonstrate the Argument Promotion concept by reducing the number of method to two.in java Write a RainFall class that stores the total rainfall for each of 12 months into an array ofdoubles. 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 rainDemonstrate the class in a complete program.Input Validation: Do not accept negative numbers for monthly rainfall figures.public class TwoColors 10 { public static void main(String[] args) { Scanner in = new Scanner(System.in); 11 12 13 14 System.out.print("Enter your first favorite color: "); 15 16 // Step 2: Read in the next line of input and assign • it to a String variable color1 17 // 18 19 // Step 3: Trim spaces from both end and convert the // // 20 input to all lowercase and assign it back 21 22 to the same variable 23 24 System.out.print("Enter your second favorite color: "); 25 26 // Step 4: Read in the next line of input and assign 27 // it to a String variable color2 28 29 30 // Step 5: Trim spaces from both end and convert the // // 31 input to all lowercase and assign it back 32 33 to the same variable 34 35 // Step 6: Display a message according to the following: // 36 first color 37 second color message light blue 38 red That's wonderful! light blue 39 red That's even better! That's also great! 40 otherwise 41 42
- // Step 1: Import Java classes Arrays, Random, and Scanner 2 3 /** 4 * A class to generate a random int array then call static. 5 * methods to sort and display the array elements. 6 * 7 *Step 2: Enter your name for @author and today's date for @version 8 * @author 9 * @version 10 */ 11 public class StaticMethodApp 12 { 13 public static void main(String[] args) I { Scanner in = new Scanner(System.in); System.out.print("Enter an integer: "); // Step 3: While the next input token is not an integèr 11 Read the input token 11 Display a message 11 Sample message, assuming the input is Java Not an integer: "Java" // // Display the same promt again // Step 4: Read the integer and store it in a variable // Step 5: Create a Random object using the input integer System.out.print("Enter the array length: "); int length = in.nextInt (); // Step 6: Create an array of int of 80 F2 F3 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 esc : F1 B # S $ 000 000 F4 % A F5 MacBook Air F6…mport java.util.Scanner; public class ParkingCharges { // function to calculate the basic charge using the asked hours static double getBasicCharge(int hours) { if (hours >= 7 && hours <= 8) return 5.50; else if (hours >= 5 && hours <= 6) return 4.50; else if (hours >= 2 && hours <= 4) return 4.00; return 3.00; } // function to return the amount to subtract based on local living and OAP static double getDiscount(String isLocal, String isOAP) { if (isOAP.equals("Yes") && isLocal.equals("Yes")) return 2.0 + 1.0; else if (isOAP.equals("Yes")) return 2.0; else if (isLocal.equals("Yes")) return 1.0; return 0; } public static void main(String[] args) { // create a new Scanner object Scanner sc = new Scanner(System.in); // prompt the user to ask if they are disabled…Explain the following code.import java.text.DecimalFormat;public class Time1 extends Object {private int hour;private int minute;private int second;public Time1(){setTime( 0,0,0 );}public void setTime( int h, int m, int s ){hour = ( ( h >= 0 && h < 24 ) ? h : hour );minute = ( ( m >= 0 && m < 60 ) ? m : minute );second = ( ( s >= 0 && s < 60 ) ? s : second );}public String toUniversalString(){DecimalFormat twoDigits = new DecimalFormat( "00" );return twoDigits.format( hour ) + ":" +twoDigits.format( minute ) + ":" + twoDigits.format( second );}public String toStandardString(){DecimalFormat twoDigits = new DecimalFormat( "00" );return ( (hour == 12 || hour == 0) ? 12 : hour % 12 ) + ":" +twoDigits.format( minute ) + ":" + twoDigits.format( second ) +( hour < 12 ? " AM" : " PM" );}}public class TimeTest1 {public static void main( String args[] ){Time1 time = new Time1();String output = "The initial universal time is: "…
- public class Polygon { private double sideLength; private int sides; private String shape; public double getArea () { int n sides; double a sideLength; return ((a * a * n) / (4 * Math.tan((180 / n) 3.14159 / 180))); public void setPolygon (double sl, int sd, String sh) { sides-sd; sideLength-sl; shape=sh; public Polygon (double sl, int sd, String sh) ( sides-sd; sideLengthsl; shape=sh; public String getShape () { return (shape); } public int getSides () { return (sides); } public double getLength () { return (sideLength); } Write a static method named find that takes as a parameter an array of type Polygon named list. The method should print the shapes of each polygon that has an area greater than 500 and return their count. The method prototype is public static int find (Polygon [] list); Note: assume the array is already declared, populated with data in the main method and ready to be used.import java.util.* ; public class MaxFinder { public static void main(String[] args) { //average high temperatures for Toronto according to gocanada. String temperatures = "-2 -1 4 11 18 24 27 26 21 14 7 0" ; Scanner scanner = new Scanner(temperatures) ; int hottestTemp = 0 ; int hottestMonth = 0 ; int coldestTemp = 0 ; int coldestMonth = 0 ; //-----------Start below here. To do: approximate lines of code = 14 // 0. initialize month //1. write a while loop that reads temperatures from scanner (assume you do not know how many values there will be, so use the hasNextInt() method) ; // Hint: use scanner.hasNextInt() in the loop condition // Don't forget to increment variable month //2. if this is the first month or an extreme month, update the hottestMonth,hottestTemp or coldestMonth,coldestTemp variables ; // an extreme month means the temperature for this month is > the current hottest…Write a Java class in which you include the following: 1. A main method that: a. Declares a-one dimensional array of 10 integer elements. b. Asks the user to fill the array. c. Ask the user to enter an integer x. d. Calls the method in question 2. e. Print the result of the method. 2. A java method named "find" that accepts a one-dimensional array as a first parameter, and an integer x as a second parameter. The method should find and return the number of occurrences of x in the array.