What is mixing data types, JAVA Programming

Assignment Help:

What is Mixing Data Types?

As well as merging various operations, you can mix and match various numeric data types on the similar line. The program below uses both ints and doubles, for instance.
class IntAndDouble {

public static void main (String args[]) {

int i = 10;
double x = 2.5;
double k;

System.out.println("i is " + i);
System.out.println("x is " + x);

k = i + x;
System.out.println("i + x is " + k);
k = i * x;
System.out.println("i * x is " + k);
k = i - x;
System.out.println("i - x is " + k);
k = x - i;
System.out.println("x - i is " + k);
k = i / x;
System.out.println("i / x is " + k);
k = x / i;
System.out.println("x / i is " + k);

}

}
This program generates the following output:
% java IntAndDouble
i is 10
x is 2.5
i + x is 12.5
i * x is 25
i - x is 7.5
x - i is -7.5
i / x is 4
x / i is 0.25
%


Related Discussions:- What is mixing data types

Create child processes, Using Fork() and Exec() or Clone(), create four ch...

Using Fork() and Exec() or Clone(), create four child processes. Load the same "Hello" program in each process after creation. This program should behave differently in each pro

File I/O, Write a program that reads both the girl and boy files into memor...

Write a program that reads both the girl and boy files into memory using arrays. Then, allow the user to input a name. The program should search through both arrays. If there is

Terminology, what is mearnt by a variable in java

what is mearnt by a variable in java

Train ticket, Write a program that manages a list of train tickets, JAVA Pr...

Write a program that manages a list of train tickets, JAVA Programming

Java project illustrate sequential and selection programming, This project ...

This project focuses on demonstrating the understanding of data types, input/output, sequential and selection programming statements, and mathematical operations. The project re

Minimum Passing Credential, Alia is appearing for the board exams. In order...

Alia is appearing for the board exams. In order to qualify for the next class Alia need to get exactly X credits. In current semester Alia has to study N number of subjects, and ev

Implement the main program with user interface, You can now implement the m...

You can now implement the main program with its user interface for this assignment in the class MovieBrowse. This will provide a simple, command-line, interactive interface to prov

How to drawing images at actual size, How to Drawing Images at Actual Size ...

How to Drawing Images at Actual Size Once the image is loaded draw it in the paint() method by using the drawImage() method like this g.drawImage(img, x, y, io) img is a

Listening for roster and presence changes, The typical use of the roster cl...

The typical use of the roster class is to display a tree view of groups and entries along with the current presence value of each entry. As an example, see the image showing a Rost

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd