Finish the Java program inputNewPlayerLocation: to input (x,y) coordinates from user (using Scanner), then return a Point object with those coordinates. swapPoints: to swap the coordinates of two Point objects. (Hint: To keep the main function's reference variables relevant, you can't swap Point objects entirely. You need to change the x and y coordinates inside the Point objects.)
Q: Write a python program that takes input values as integer, checks the number is not less than 10…
A: Given: Create another class ‘Intern’ and inherit ‘Employee’ as super class. Concatenate the integer…
Q: public abstract class DebugBoat { String boatType = new String(); int passengers String…
A: public abstract class DebugBoat{ String boatType = new String(); int passengers; String power…
Q: Create a new class called Simplecalc. In this class, implement a program that asks the user to enter…
A: // Java program for simple calculator import java.io.*;import java.lang.*;import…
Q: Write a java program that enables the user to enter a string and an index,then cuts the letter in…
A: Algorithm: Start Read a string s Read index Set s=s.substring(0,index) +…
Q: Write a program in the Java code that modifies the function to test the number as follows: 2_If the…
A: The function toTest() ask user to enter a number which is then compared with the already initialised…
Q: Write a java method that takes a full name from the user, and converts each start letter in the…
A: 1. make an object of the scanner class 2. input a string 3. call the function 4. split the string…
Q: Write a java program to perform the following operations using method overloading i)Get two strings…
A: Method overloading is a form of polymorphism in OOP.
Q: Complete the following program in java to implement the user interface of the preceding exercise.…
A: A Java program is as follows, File name: “UnitConverter.java” import java.util.Scanner; import…
Q: Write a function MyImage method to compute histogram, public int[] hist (int bandno) of a specified…
A: Before writing the method the declarations needs to be done int k =…
Q: Write a JAVA program with class name as Exam using Mutable objects to calculate the volume of…
A: Volume is three-dimensional space and is denoted by a standard unit of “meter” in physics. Volume…
Q: Use Java program to add a method printReceipt to the CashRegister class. Then create a driver class…
A: The two additional methods are to be added to the CashRegister class. The methods are addItem and…
Q: Write a java program to simulate a car insurance We have a problem, which is calculating the…
A: Here i explain it clearly. ============================================================ you want to…
Q: Write Java classes to implement the following: Problem 1. Input three strings s1, s2, and s3 from…
A: According to the question below the solution: Output:
Q: Write a java program using Encapsulation for the following class diagram. Get the values of name, id…
A: Student.java ======================= import java.util.Scanner; public class Student { //declaring…
Q: Use Java program to add a method printReceipt to the CashRegister class. The method should ask the…
A: Use two arrays one to store names and other to store prices
Q: Write a complete Java program that prints out the following information: Ask the user to enter the…
A: The main objective of the java program, Rabab.java is to prompt the user to enter the last three…
Q: By default, which one of the following types of values will be thrown when the below function is…
A: The problem is based on the basics of functions in python programming language.
Q: Implement the design of the Travel class in python so that the following output is produced: You…
A: Algorithm: Start Implement class Travel with a static variable count and class variables…
Q: Write a java program to print the area of a rectangle by creating a class named 'Area' having two…
A: The required Java code is given below: import java.util.Scanner;public class Area{ // class Area…
Q: Write a class calculator to perform addition and subtraction. Create 3 calculator objects with…
A: **This code is written in JAVA since no other programming language was mentioned.** class…
Q: This program will have 4 states: HAPPY, HUNGRY, BORED, SAD. Here are the rules. Our animal starts…
A: Please refer to the following steps for the complete solution to the problem above.
Q: I need to do this in python, help. 7- create a class that represents a point on the Cartesian…
A: Python program to create two classes point and triangle that do the required function mentioned in…
Q: Write a Java program that asks the user to enter two Strings. Then, uses String method compareTo()…
A: String Comparison is done by comparing one character at a time from both the strings and whenever…
Q: Write up Java source codes for compiling and execution of program below. Draw UML diagram for codes.…
A: the code is an given below : import javax.swing.JButton; import javax.swing.JFrame; import…
Q: Solve the question with python Design Foodcart class and Food class so that the following code…
A: Actually, python is a easiest programming language. It has a concise(less) code. It is a…
Q: Take a string and a word from user and check whether this word is present in that string or not.…
A: Required:- Take a string and a word from the user and check whether this word is present in that…
Q: Is there a built-in JAVA method that accepts two arrays as parameters and returns true if both…
A: Introduction: Is there a built-in JAVA method that accepts two arrays as parameters and returns…
Q: Develop a Java program using NetBeans , that initially display a menu to the user. The menu should…
A: Given: Develop a Java program using NetBeans , that initially display a menu to the user. The menu…
Q: I need help adding a new line at the end of the output string here is my Java code, and it is all…
A: There are two ways to put a new line after the output is printed in the given code. Given JAVA code:…
Q: Please make a method to convert from binary to decimal and vice versa A “Procedural CLI Calculator”…
A: Lets see the solution.
Q: Implement the design of the Bird class so that the following output is produced: # Write your…
A: code : - # Write your codes here.class Bird: # class variable count = 0 #…
Q: Write a java program using Encapsulation for the following class diagram. Get the values of name, id…
A: Encapsulation is an OOPs concept of wrapping the data member and method that acting on the data…
Q: Create a Java program with a function that accepts an object's mass (in kilograms) and velocity (in…
A: Use double datatype for m,v,E
Q: What is the problem with the followingfunction? static void testFunction(String title, int ... v,int…
A: Here the code consist of function testFunction which has three arguments title,v and y. Here the for…
Q: Write a method in java that validates that the input from the user is of type double. Set the…
A: - We need to highlight the code of input validation to check the input type being double only.
Q: Implement a Java method with the identifier “SquareRoot” that takes 1 parameter of type integer and…
A: Importing modules scanner to read input Creating class findsquareroot Create main method Create…
Q: For this assignment, write a program called Payday.java that will compute and print a person's…
A: Given:
Q: Po In the space below, write the six lines of output when the following Java code fragment is run.…
A: public class Main{ public static void main(String[] args) {double go= 10;int fight = 20;int win =…
Q: What will be the output of the following program snippet: With static scoping a) 2 4 b) 3 1…
A: Please upvote. I am providing you the correct answer below. Please please please.
Q: sing suitable rendering, you can assign different random colors -of course all of the colors are of…
A:
Q: Write a Java Program to Find Area of Square, Rectangle and Circle using constructor Overloading.
A: Constructors have same name of the class but with number of arguments. Constructors can be…
Q: Java - How to make this a horizontal statement with a newline. Whenever I use System.out.println, it…
A: We need to find method of how to make a horizontal statement with a newline. If System.out.println…
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: THIS IS MEANT TO BE WRITTEN IN JAVA. The assignment is to get an integer from input, and output…
A: /*Get an integer from input, and output that integer squared, ending with newline.*/ import…
Q: PLEASE HELP ME FIND THE JAVA CODE FOR THIS PROBLEM 2. Rectangle by CodeChum Admin A rectangle…
A: The program is given below:- class Point { // x and y-coordinate double x; double y;…
Q: Write a java program called Sales considering the following directions and the sample run. Practice…
A: The program has the following steps:Declare the variablesReceive the input from the userCalculate…
Q: your askForYesNo method, how would you get the same result with only using one if/else if/else…
A: With your askForYesNo method, how would you get the same result with only using one if/else if/else…
Q: For this assignment, write a program called Payday.java that will compute and print a person's…
A: Required: For this assignment, write a program called Payday.java that will compute and print a…
Q: Create a java program using user defined function. Create a function/method void: -showinfo with…
A: public class Main{ public static void showinfo(int A1, String FN, String LN, String MI, int A2)…
Q: here is a very simple solution to keeping Tic-tac-toe fresh and interesting, though, and it has been…
A: the code is an given below : import javax.swing.JButton; import javax.swing.JFrame; import…
Finish the Java
- inputNewPlayerLocation: to input (x,y) coordinates from user (using Scanner), then return a Point object with those coordinates.
- swapPoints: to swap the coordinates of two Point objects. (Hint: To keep the main function's reference variables relevant, you can't swap Point objects entirely. You need to change the x and y coordinates inside the Point objects.)
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
- Explain this java code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(http://System.in); int[][] seats = new int[10][4]; System.out.println("Bus Seat Reservation:"); while (true) { System.out.println("Col 1 Col 2 Col 3 Col 4"); for (int i = 0; i < seats.length; i++) { System.out.print("row " + (i + 1) + " | "); for (int j = 0; j < seats[i].length; j++) { System.out.print(seats[i][j] == 0 ? "* " : "X "); } System.out.println(); } System.out.print("Enter row and column no. to reserve separated by space (enter negative no. to exit): "); int row = in.nextInt(); int column = in.nextInt(); if (row < 0 || column < 0) { System.out.print("Program Exit"); break; } seats[row - 1][column…import java.util.Scanner; public class LabProgram { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int n = scnr.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = scnr.nextInt(); } for (int i = n - 1; i >= 0; i--) { System.out.print(arr[i]); if (i > 0) { System.out.print(","); } } }}I need help with my Java compiler Generating the final machine code, such as x86 assembly language, that can be executedon a computer. import java.util.*; public class SimpleCalculator { private final String input;private int position;private boolean hasDivByZero = false;private Map<String, String> symbolTable;private List<String> instructions; public SimpleCalculator(String input) {this.input = input;this.position = 0;this.symbolTable = new HashMap<>();this.instructions = new ArrayList<>();} public static void main(String[] args) {SimpleCalculator calculator = new SimpleCalculator("3 + 5 * (2 - 1)");calculator.parseExpression();if (calculator.hasDivByZero) {System.out.println("Error: division by zero");} else {System.out.println("Result: " + calculator.instructions);}} public void parseExpression() {parseTerm('+');} public String parseTerm(char op) {String t1 = parseFactor(); while (peek() == op || peek() == '/') {char operator = consume();String t2 =…
- import java.util.Scanner; public class CharMatch { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); String userString; char charToFind; int strIndex; userString = scnr.nextLine(); charToFind = scnr.next().charAt(0); strIndex = scnr.nextInt(); /* Your code goes here */ }}import java.util.Scanner; public class ContactList { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); ContactNode head = null; ContactNode current = null; // Read the name and phone number for three contacts and build a linked list. for (int i = 1; i <= 3; i++) { System.out.print(" " + i + ": "); String name = scnr.next(); System.out.print(" " + i + ": "); String phoneNumber = scnr.next(); ContactNode newContact = new ContactNode(name, phoneNumber); if (head == null) { head = newContact; current = head; } else { current.insertAfter(newContact); current = newContact; } } // Output each contact. current = head; for (int i = 1; current != null; i++) { System.out.print("Person " + i + ": "); current.printContactNode();…package com.java.runner;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import com.java.model.StudentRecord;public class Runner {public static void main(String[] args) {StudentRecord erlynRecord = new StudentRecord();StudentRecord erickRecord = new StudentRecord();erlynRecord.setName("Erlyn");erlynRecord.setAddress("Taguig");erlynRecord.setAge(20);erlynRecord.setMathGrade(85.3);erlynRecord.setScienceGrade(82.2);erlynRecord.setEnglishGrade(78.6);System.out.println("Name: " + erlynRecord.getName());System.out.println("Address: " + erlynRecord.getAddress());System.out.println("Age: " + erlynRecord.getAge());System.out.println("Math Grade: " + erlynRecord.getMathGrade());System.out.println("Science Grade: " + erlynRecord.getScienceGrade());System.out.println("English Grade: " + erlynRecord.getEnglishGrade());System.out.println("Average Grade: " +…
- package com.java.runner;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.ArrayList;import com.java.model.StudentRecord;public class Runner {public static void main(String[] args) {StudentRecord erlynRecord = new StudentRecord();StudentRecord erickRecord = new StudentRecord();erlynRecord.setName("Erlyn");erlynRecord.setAddress("Taguig");erlynRecord.setAge(20);erlynRecord.setMathGrade(85.3);erlynRecord.setScienceGrade(82.2);erlynRecord.setEnglishGrade(78.6);System.out.println("Name: " + erlynRecord.getName());System.out.println("Address: " + erlynRecord.getAddress());System.out.println("Age: " + erlynRecord.getAge());System.out.println("Math Grade: " + erlynRecord.getMathGrade());System.out.println("Science Grade: " + erlynRecord.getScienceGrade());System.out.println("English Grade: " + erlynRecord.getEnglishGrade());System.out.println("Average Grade: " +…please write it in C language. import java.util.*; public class EightQDfs { final int X = 4; void dispSol(int brd[][]) { for(int i = 0; i < X ; i++) { for(int j=0 ; j < X ; j++) { System.out.print(" " + brd[i][j]) + " "); System.out.println(); } } boolean isSafe(int brd[][] , int r , int c) //r is for row and c is column { int i , j; for(i = 0 ; i < c ; i++) if(brd[r][i] == 1) return false; for(i = r ; j = c ; i >=0 && j >= 0 ;i-- ,j--) if(brd[i][j] == 1) return false; for(i = r , j = c ; j >= 0 && i < X ; i++ , j--) if(brd[i][j] == 1) return false; return true; } boolean EQsolved(int brd[][] , int c) { if(c >= X) return true; for(int i= 0; i < X ;i++) { if(isSafe(brd , i , c)) { brd[i][c] = 1; if(EQsolved(brd , c + 1) == true ) return true; brd[i][c] = 0 ; } } return false; } boolean…import java.util.Scanner; public class SportsBus extends Bus { private int competitorArea; private int numSecurity; private Bus bus; public SportsBus(Bus b, int competitorArea, int numSecurity) { super(b.getName(), b.getSize(), b.getPrice(), b.getLevel(), b.getMinistry()); bus = b; this.competitorArea = competitorArea; this.numSecurity=numSecurity; } mport java.util.Scanner; public class TrainingBus extends Bus { private int teacherArea; public TrainingBus(Bus b, int teacherArea) { super(b.getName(), b.getSize(), b.getPrice(), b.getLevel(), b.getMinistry()); this.teacherArea = teacherArea; } import java.util.Scanner; public class PartyBus extends SportsBus{ int barArea; public PartyBus(SportsBus s, int barArea) { super( s.getBus(), s.getCompetitorArea(), s.getNumSecurity()); this.barArea = barArea; }…
- Please sort out the following JAVA code....line by line. Run the code in Netbeans and provide screenshots to verify that it runs successfully. CODE: import java.io.*; import java.util.*; public class experiment { public static void main(String args[]) { Scanner in=new Scanner(System.in); int time[]=new int[10]; float weight[]=new float[10]; String get; char ch; int i=0; do{ try { System.out.print("\nEnter the time in seconds:"); time[i]=in.nextInt(); System.out.print("\nEnter the weight in kilograms:"); weight[i]=in.nextFloat(); i++; } catch(Exception e) { System.out.print("\nInvalid type"); } System.out.print("\n-----------------"); System.out.print("\n|Time\t|Weight\t|"); System.out.print("\n-----------------"); for(int x=0;x<i;x++) { System.out.print("\n|"+time[x]+"\t|"+weight[x]+"\t|"); System.out.print("\n-----------------"); } if(i==10) { for(int x=0;x<9;x++) { time[x]=time[x+1]; weight[x]=weight[x+1]; } i--; } System.out.print("\nDo you want to continue?(y/n) ");…import java.util.Scanner; public class ParkingFinder {/* Your code goes here */ public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int numVisits; int duration; numVisits = scnr.nextInt(); duration = scnr.nextInt(); System.out.println(findParkingPrice(numVisits, duration)); }}Can you make it more efficient and paraphrase it in Java import java.lang.Math;import java.util.*; import javax.xml.stream.events.EndDocument; public class KiK{ private static int boardSize = 12; private static int rand; public static Integer [] randomGenotype() { Integer [] genotype = new Integer [boardSize]; for(int i=0; i<genotype.length; i++) { genotype[i] = 0; } rand = (int)(Math.random()*boardSize +1); for(int i=0; i<genotype.length; i++) { while(checkArray(genotype, rand)) { rand = (int)(Math.random()*boardSize +1); } genotype[i] = rand; } return genotype; } private static boolean checkArray(Integer[] arr, int num) { for(int i=0; i<arr.length; i++) { if(arr[i] == num) {return true;} } return false; } public static Integer[]…