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
- import java.util.Scanner; public class InstrumentInformation { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Instrument myInstrument = new Instrument(); StringInstrument myStringInstrument = new StringInstrument(); String instrumentName, manufacturerName, stringInstrumentName, stringManufacturer; int yearBuilt, cost, stringYearBuilt, stringCost, numStrings, numFrets; boolean bowed; instrumentName = scnr.nextLine(); manufacturerName = scnr.nextLine(); yearBuilt = scnr.nextInt(); scnr.nextLine(); cost = scnr.nextInt(); scnr.nextLine(); stringInstrumentName = scnr.nextLine(); stringManufacturer = scnr.nextLine(); stringYearBuilt = scnr.nextInt(); stringCost = scnr.nextInt(); numStrings = scnr.nextInt(); numFrets = scnr.nextInt(); bowed = scnr.nextBoolean(); myInstrument.setName(instrumentName); myInstrument.setManufacturer(manufacturerName);…import java.util.Scanner; public class PetInformation {public static void main(String[] args) {Scanner scnr = new Scanner(System.in); Pet myPet = new Pet(); Cat myCat = new Cat(); String petName, catName, catBreed; int petAge, catAge; petName = scnr.nextLine(); petAge = scnr.nextInt(); scnr.nextLine(); catName = scnr.nextLine(); catAge = scnr.nextInt(); scnr.nextLine(); catBreed = scnr.nextLine(); // Create generic pet (using petName, petAge) and then call printInfo myPet.setName(petName); myPet.setAge(petAge); myPet.printInfo(); // Create cat pet (using catName, catAge, catBreed) and then call printInfo myCat.setName(catName); myCat.setAge(catAge); myCat.setBreed(catBreed); myCat.printInfo(); // Use getBreed(), to output the breed of the cat System.out.println(" Breed: " + myCat.getBreed());}}UML diagram for the java code below public class CourseDBManager implements CourseDBManagerInterface { private CourseDBStructure dataMgr = new CourseDBStructure(20); public void readFile(File inputFile) throws FileNotFoundException{ try { Scanner fileData = new Scanner(inputFile); while(fileData.hasNext()) { String id = fileData.next(); int crn = fileData.nextInt(); int numCredits = fileData.nextInt(); String roomNum = fileData.next(); String instructor = fileData.nextLine(); add(id, crn, numCredits, roomNum, instructor); } fileData.close(); } catch(FileNotFoundException e) { System.out.print("File not found"); e.getMessage(); } } public void add(String id, int crn, int credits, String roomNum, String instructor) { CourseDBElement newElement = new CourseDBElement(id, crn, credits, roomNum, instructor); dataMgr.add(newElement); } public…
- import java.util.Scanner; public class Inventory { public static void main (String[] args) { Scanner scnr = new Scanner(System.in); InventoryNode headNode; InventoryNode currNode; InventoryNode lastNode; String item; int numberOfItems; int i; // Front of nodes list headNode = new InventoryNode(); lastNode = headNode; int input = scnr.nextInt(); for(i = 0; i < input; i++ ) { item = scnr.next(); numberOfItems = scnr.nextInt(); currNode = new InventoryNode(item, numberOfItems); currNode.insertAtFront(headNode, currNode); lastNode = currNode; } // Print linked list currNode = headNode.getNext(); while (currNode != null) { currNode.printNodeData(); currNode…Question 2. package sortsearchassigncodeex1; import java.util.Scanner; import java.io.*; // // public class Sortsearchassigncodeex1 { // public static void fillArray(Scanner inputFile, int[] arrIn){ int indx = 0; //Complete code { arrIn[indx] = inputFile.nextInt(); indx++; } }import java.util.Scanner; public class CourseInformation { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Course myCourse = new Course(); OfferedCourse myOfferedCourse = new OfferedCourse(); String courseNumber, courseTitle; String oCourseNumber, oCourseTitle, instructorName, location, classTime; courseNumber = scnr.nextLine(); courseTitle = scnr.nextLine(); oCourseNumber = scnr.nextLine(); oCourseTitle = scnr.nextLine(); instructorName = scnr.nextLine(); location = scnr.nextLine(); classTime = scnr.nextLine(); myCourse.setCourseNumber(courseNumber); myCourse.setCourseTitle(courseTitle); myCourse.printInfo(); myOfferedCourse.setCourseNumber(oCourseNumber); myOfferedCourse.setCourseTitle(oCourseTitle); myOfferedCourse.setInstructorName(instructorName); myOfferedCourse.setLocation(location); myOfferedCourse.setClassTime(classTime);…
- import java.util.Scanner;public class LabProgram { public static void main(String args[]) { Scanner scnr = new Scanner(System.in); int credits; int seed; GVDie die1, die2; die1 = new GVDie(); die2 = new GVDie(); // Read random seed to support testing (do not alter) seed = scnr.nextInt(); die1.setSeed(seed); // Read starting credits credits = scnr.nextInt(); int rounds = 0; while (credits > 0) { // Step 1: Roll both dice die1.roll(); die2.roll(); int total = die1.getValue() + die2.getValue(); if (total == 7 || total == 11) { // Player wins one credit credits++; // UPDATE - print the dice total here System.out.println("Dice total: " + total); //UPDATE - break the loop and end the round break; } else if (total == 2 ||…import java.util.Scanner; public class LabProgram { public static void main(String args[]) { Scanner scnr = new Scanner(System.in); int credits; int seed; GVDie die1, die2; die1 = new GVDie(); die2 = new GVDie(); // Read random seed to support testing (do not alter) seed = scnr.nextInt(); die1.setSeed(seed); // Read starting credits credits = scnr.nextInt(); int rounds = 0; while (credits > 0) { // Step 1: Roll both dice die1.roll(); die2.roll(); int total = die1.getValue() + die2.getValue(); if (total == 7 || total == 11) { // Player wins one credit credits++; } else if (total == 2 || total == 3 || total == 12) { // Player loses one credit credits--; } else { // Set the goal for future rolls int goal = total;…import java.util.Arrays; import java.util.Scanner; public class Game { private Player[] players; private Board board; private int currentPlayerIndex; private int numOfPlayers; private Scanner scanner = new Scanner(System.in); // constructor public Game(){ //create a new board; this.board = new Board(); //setup game; this.setupGame(); //start game; this.play(); } //Game Setup public void setupGame(){ System.out.println("How many players would you like to included in this game? (2-4)"); numOfPlayers = scanner.nextInt(); while (numOfPlayers < 2 || numOfPlayers > 4) { System.out.println("Invalid input. Please enter a number between 2 and 4."); numOfPlayers = scanner.nextInt(); } scanner.nextLine(); String[] playerNames = new String[numOfPlayers]; this.players = new…
- import java.util.Scanner; public class MealEstablishmentDirectory { public static void main (String[] args) { Scanner scnr = new Scanner(System.in); int newRating; String newState; MealEstablishment mealEstablishment1 = new MealEstablishment(); System.out.println("Default values: "); mealEstablishment1.print(); newRating = scnr.nextInt(); newState = scnr.next(); mealEstablishment1.setRating(newRating); mealEstablishment1.setState(newState); System.out.println("After mutator methods: "); mealEstablishment1.print(); } }import java.util.Scanner; public class WinningTeam { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Team team = new Team(); String name = scnr.next(); int wins = scnr.nextInt(); int losses = scnr.nextInt(); team.setName(name); team.setWins(wins); team.setLosses(losses); team.printStanding(); }}import java.util.Scanner; public class WinningTeam { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); Team team = new Team(); String name = scnr.next(); int wins = scnr.nextInt(); int losses = scnr.nextInt(); team.setName(name); team.setWins(wins); team.setLosses(losses); team.printStanding(); }} This is the second part of the program and not geting it to run public class Team { // TODO: Declare private fields - name, wins, losses private String name; private int wins; private int losses; public int getlosses(){ return losses; } // TODO: Define mutator methods - // setName(), setWins(), setLosses() public String setName(){//String name int wins int losses return name; } public int setWins(){ return wins; } public int setLosses(){ return losses; } // TODO: Define accessor methods - //…