Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please, i need Unique answer, Use your own words (don't copy and paste). *Please, don't use handwriting. Given the code above: Find the errors (either

Please, i need Unique answer, Use your own words (don't copy and paste).

*Please, don't use handwriting.

image text in transcribed

Given the code above:

  1. Find the errors (either compile or run-time error) so that you have the same output listed below then state the type of the error.
  1. After you fixed the errors, rewrite the Java code using your name (Sara)
  1. Show a screenshot of the output (if there is no screenshot of the output, the student shall get a zero mark for this question).

image text in transcribed

_______________________________________

Q2

Consider the following java application consisting of two classes, and then answer the questions below.

image text in transcribed

image text in transcribed

  1. Find and fix the errors in the previous application.
  2. What is the output of the previous application? (What will be printed on the console window when CarTester class is executed)?
  3. What are the values of (model) and (year) variables for the object variable car1 and why?

_______________

Q3

Write a program that asks the user to enter two integers and then print:

The sum

The difference

The product

The average

The maximum (the larger of the two)

The minimum (the smaller of the two)

Hint: The max and min functions are declared in the Math class.

_________________________

Q4

  1. Create a class "Mobile" with the following specifications: brand, color, screen size and camera size as field.
  2. Declare the instance variableswith suitable data types.
  3. Define a constructor that allow the initialization of all the data of a mobileby specific values.
  4. Define all the needed getter methods: getBrand(), getColor(), getScreen() and getCamera().
  5. Write a tester class. In the main, create twophones then, display the details of each one.
public class Students public static void main (String args) String s1"Java Programming" String s2"at seu" String s3- "Type your ne "; System.out.print (S1) System.out.print("" System.out.println (s2.toupperCase)) System.out.println (s3) System.out.println( "This is my first Assignment" System.out.print (s1.replace ("java""cs140")) System.out.print("" System.out.println (s2.toLowerCase)) System.out.print (8 8) System.out.print (" = "); System.out.println (s1.length(5)) Output -Students (run) run: Java Programming AT SEU My name is Mohammed F. Ali! n This is my first Assignment CS140 Programming at seu 8+8e 16 Error number Error Type 1 System.out.print(S1), Compile-time error 4 Class1: public class Car( private string modeli privateat year; publig Car ) model= "" year, = 0; publis Car (String model, int year) this.mode = model; this, year = year; public tring shangeModel (String model) this . mode model; = string getModel return model: public J. public void changeYear (int year) t this.ye a r = year; publicintgetYear) yeas Class2: publig class CarTester publis static void main (String[] args) Car car1 = new Car ("Toyota", 2017); System.outaprintln(car1.getModel )) System.outaprintln(car1.getYear)) Car car2 = car 1 ; car2.Model ("Nissan" car2.changeYear (1999); System.outaprintln(car2.getModel )) System.out println(car2.Year ))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

Used to query a database. CRM SCM RFID SQL XML ERP EDI SaaS

Answered: 1 week ago

Question

Explain the factors influencing wage and salary administration.

Answered: 1 week ago

Question

Examine various types of executive compensation plans.

Answered: 1 week ago

Question

1. What is the meaning and definition of banks ?

Answered: 1 week ago