Question 1: Write a program that includes a method that checks a number given to it as a parameter if that number is positive, negative or zero. The program should ask the user to enter a number and then by calling the method it would decide whether the number entered is positive, negative or zero.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 15PE
icon
Related questions
Question

java language solve question 1

Question 1:
Write a program that includes a method that checks a number given to it
as a parameter if that number is positive, negative or zero.
The program should ask the user to enter a number and then by calling
the method it would decide whether the number entered is positive,
negative or zero.
**************
********
Transcribed Image Text:Question 1: Write a program that includes a method that checks a number given to it as a parameter if that number is positive, negative or zero. The program should ask the user to enter a number and then by calling the method it would decide whether the number entered is positive, negative or zero. ************** ********
************
Question 2:
Check the following pieces of code. Is the overloading done in them
correct or wrong?
Code 1:
int sum(int a, int b)
{ return (a+b); }
double sum(double a, double b)
{ return (a+b); }
Code 2:
double max ( double x, int y)
{ double rr;
rr = x>y? x : y;
return rr;}
double max (int x, double y)
{ double rr;
rr = x>y? x = y;
return rr; }
Code 3:
void myPrint(int cc)
{ System.out.println(cc);}
void myPrint()
{ System.out.println("Hello"); }
*********
************
1
***********
Transcribed Image Text:************ Question 2: Check the following pieces of code. Is the overloading done in them correct or wrong? Code 1: int sum(int a, int b) { return (a+b); } double sum(double a, double b) { return (a+b); } Code 2: double max ( double x, int y) { double rr; rr = x>y? x : y; return rr;} double max (int x, double y) { double rr; rr = x>y? x = y; return rr; } Code 3: void myPrint(int cc) { System.out.println(cc);} void myPrint() { System.out.println("Hello"); } ********* ************ 1 ***********
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Function Calling
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage