TutorMe homepage
Subjects
PRICING
COURSES
SIGN IN
Start Free Trial
Haytham E.
Senior Instructor in Java , database concepts data structure and Oracle and Teach most courses of Computer Science
Tutor Satisfaction Guarantee
Java Programming
TutorMe
Question:

This code: final double d = 1 / 2; System.out.println(d); prints 0. Why? How do you make this code print 0.5 instead?

Haytham E.
Answer:

The problem here is that this expression: 1 / 2 has integer literals on both sides of the operator: 1 and 2. As a consequence, an integer division will be performed, and the result of 1 divided by 2 of an integer division is 0. In order for the result to be a double as expected, at least one operand of the operation needs to be a double. For instance: final double d = 1 / 2.0; or: final double d = 1.0 / 2;

HTML Programming
TutorMe
Question:

3) Write an HTML table tag sequence that outputs the following: 50 pcs 100 500 10 pcs 5 50

Haytham E.
Answer:

<table> <tr> <td>50 pcs</td> <td>100</td> <td>500</td> </tr> <tr> <td>10 pcs</td> <td>5</td> <td>50</td> </tr> </table>

Databases
TutorMe
Question:

What is wrong with the SQL query below? SELECT UserId, AVG(Total) AS AvgOrderTotal FROM Invoices HAVING COUNT(OrderId) >= 1

Haytham E.
Answer:

The issue here is that there must be a GROUP BY clause here. This query will get the average order amount by the customer (UserId) where the customer has at least 1 order. The correct query is listed below: SELECT UserId, AVG(Total) AS AvgOrderTotal FROM Invoices GROUP BY Userid HAVING COUNT(OrderId) >= 1

Send a message explaining your
needs and Haytham will reply soon.
Contact Haytham
Ready now? Request a lesson.
Start Session
FAQs
What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Session" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.