Computer Science, asked by manjusengar914, 9 months ago

define a class with the following members :data member: integer type num1 floating point num2 double num3 function (): getdata() take no argument and has int return value . calc() take double argument and return a double. sum() takes two int arguments and return an in type.

Answers

Answered by ramabisa
6

Answer:

Explanation:

This is the JAVA program for the given question:

import java.util.Scanner;

class data

{

int num1;

float num2;

double num3;

getdata()

{

System.out.println(num1); //most likely the output for this print statement is going to be 0 because num1 is an integer data type

}

calc()

{

Scanner in = new Scanner(System.in);

System.out.println("Enter a double value");

num3 = in.nextDouble();

System.out.println("Double value: " + num3);

}

sum()

{

Scanner in = new Scanner(System.in);

System.out.println("Enter the first argument");

int n1 = in.nextInt();

System.out.println("Enter the second argument");

int n2 = in.nextInt();

int sum = n1 + n2;

System.out.println("Sum of the given integers: " + sum);

}

public void main()

{

data obj = new data();

obj.getdata();

obj.calc();

obj.sum();

}

}

}

Similar questions