IN JAVA. Please reply with the solution without changing aspects of the pre-determined code. The example is for your reference and is NOT supposed to be included in the pre-determined code. Comments are helpful, too. Thank you SO much! :)
--
Basic constructor definition.
Define a constructor as indicated. Sample output for below program:
Year: 0, VIN: -1 Year: 2009, VIN: 444555666
--
// ===== Code from file CarRecord.java =====
public class CarRecord {
private int yearMade;
private int vehicleIdNum;
// FIXME: Write constructor, initialize year to 0, vehicle ID num to -1.
/* Your solution goes here */
public void setYearMade(int originalYear) {
yearMade = originalYear;
}
public void setVehicleIdNum(int vehIdNum) {
vehicleIdNum = vehIdNum;
}
public void print() {
System.out.println("Year: " + yearMade + ", VIN: " +
vehicleIdNum);
}
}
// ===== end =====
// ===== Code from file CallCarRecord.java =====
public class CallCarRecord {
public static void main(String [] args) {
CarRecord familyCar = new CarRecord();
familyCar.print();
familyCar.setYearMade(2009);
familyCar.setVehicleIdNum(444555666);
familyCar.print();
}
}
// ===== end =====
// ===== Code from file CarRecord.java ===== class CarRecord { private int yearMade; private int vehicleIdNum; // FIXME: Write constructor, initialize year to 0, vehicle ID num to -1. //Default constructor CarRecord(){ yearMade = 0; vehicleIdNum = -1; } //Argumented constructor CarRecord(int yearMade, int vehicleIdNum){ this.yearMade = yearMade; this.vehicleIdNum = vehicleIdNum; } /* Your solution goes here */ public void setYearMade(int originalYear) { yearMade = originalYear; } public void setVehicleIdNum(int vehIdNum) { vehicleIdNum = vehIdNum; } public void print() { System.out.println("Year: " + yearMade + ", VIN: " + vehicleIdNum); } } // ===== end ===== // ===== Code from file CallCarRecord.java ===== class CallCarRecord { public static void main(String [] args) { CarRecord familyCar = new CarRecord(); familyCar.print(); familyCar.setYearMade(2009); familyCar.setVehicleIdNum(444555666); familyCar.print(); } }
OUTPUT :
IN JAVA. Please reply with the solution without changing aspects of the pre-determined code. The example...
C++ Define a constructor as indicated. Sample output for below program: Year: 0, VIN: -1 Year: 2009, VIN: 444555666 #include <iostream> using namespace std; class CarRecord { public: void SetYearMade(int originalYear); void SetVehicleIdNum(int vehIdNum); void Print() const; CarRecord(); private: int yearMade; int vehicleIdNum; }; // FIXME: Write constructor, initialize //year to 0, vehicle ID num to -1. /* Your solution goes here */ void CarRecord::SetYearMade(int originalYear) { yearMade = originalYear; } void CarRecord::SetVehicleIdNum(int vehIdNum) { vehicleIdNum = vehIdNum; } void...
JAVA Only Help on the sections that say Student provide code. The student Provide code has comments that i put to state what i need help with. import java.util.Scanner; public class TicTacToe { private final int BOARDSIZE = 3; // size of the board private enum Status { WIN, DRAW, CONTINUE }; // game states private char[][] board; // board representation private boolean firstPlayer; // whether it's player 1's move private boolean gameOver; // whether...
Please explain if the following code is actually correct. If the following code correct, please explain why the code works and is also correct. Don’t use * Java’s Integer .toBinaryString(int) in this program./* According to the textbook and the instructor, I am not supposed to use arrays such as int binary[] = new int[25]; I guess this is the reason why this problem is starting to look kind of hard. Chapter 5 Exercise 37: Java Programming * * (Decimal to...
All JAVA code 6.2.2: Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. Ex: printFeetInchShort(5, 8) prints: 5' 8" Hint: Use \" to print a double quote Sample program: import java.util.Scanner; public class HeightPrinter { /* Your solution goes here */ public static void main (String [] args) { printFeetInchShort(5, 8); System.out.println(""); return; } } 6.4.1: Define stubs for the methods called by the below main(). Each stub should print "FIXME: Finish...
Given the following Java code: public static void main (String[] args) { int num; System.out.println("Enter a number"); num = scan.nextInt(); <-first input statement while (num != 0) { System.out.println ("The number is: " + num); System.out.println("Enter a number"); num = scan.nextInt(); } //End While } //End Module The first input statement shown above is called the:
Java Write a complete program that implements the functionality of a deck of cards. In writing your program, use the provided DeckDriver and Card classes shown below. Write your own Deck class so that it works in conjunction with the two given classes. Use anonymous objects where appropriate. Deck class details: Use an ArrayList to store Card objects. Deck constructor: The Deck constructor should initialize your ArrayList with the 52 cards found in a standard deck. Each card is a...
JAVA 1. Given the following class definition, what are the contents of the fields x and y of the object p ? class MyPoint { int x; int y; public MyPoint (int x, int y){ x = x; y = y; } --------------------------------------- MyPoint p = new MyPoint( 100, 88 ); 2. static and non-static members What would happen if you tried to compile and run the following code ? public class Driver {...
please rewrite this code as Pseudo-Code,.. basically rewrite the code but in english language , Thank you so much! public abstract class BankAccount { //declare the required class variables private double balance; private int num_deposits; private int num_withdraws; private double annualInterest; private double serviceCharges; //constructor that takes two arguments // one is to initialize the balance and other // to initialize the annual interest rate public BankAccount(double balance,...
JAVA- Complete the code by following guidelines in comments. class CircularList { private Link current; private Link prev; public CircularList() { // implement: set both current and prev to null } public boolean isEmpty() { // implement return true; } public void insert(int id) { // implement: insert the new node behind the current node } public Link delete() { // implement: delete the node referred by current return null; } public Link delete(int id) { // implement: delete the...
JAVA Modify the code to create a class called box, wherein you find the area. I have the code in rectangle and needs to change it to box. Here is my code. Rectangle.java public class Rectangle { private int length; private int width; public void setRectangle(int length, int width) { this.length = length; this.width = width; } public int area() { return this.length * this.width; } } // CONSOLE / MAIN import java.awt.Rectangle; import java.util.Scanner; public class Console...