Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Other

Simple Java program for beginners

Rating
-
Sold
-
Pages
6
Uploaded on
07-09-2023
Written in
2023/2024

This document provided the 7 beggner level programs

Institution
Course

Content preview

1.Java program to print the “ Hello Java”

Import java.io.*;

Class A

{

public static void main(String args [])

{

System.out.println(“ Hello Java”);

}

}




2.Java program to take an integer as input and print it

import java.io.*;

import java.util.Scanner;

// Driver Class

class GFG {

// main function

public static void main(String[] args)

{

// Declare the variables

int num;

// Input the integer

System.out.println("Enter the integer: ");

// Create Scanner object

Scanner s = new Scanner(System.in);

// Read the next integer from the screen

num = s.nextInt();

// Display the integer

System.out.println("Entered integer is: " + num);

}

}

Input

, Enter the integer: 10

Output

Entered integer is: 10

3.Java Program to print Multiplication of two floating point Number.

import java.io.*;

class GFG {

public static void main(String[] args)

{

// f is to ensures that numbers are float DATA TYPE

float f1 = 1.5f;

float f2 = 2.0f;

// to store the multiplied value

float p = f1 * f2;

// to print the product

System.out.println("The product is: " + p);

}

}

Output

The product is: 3.0



4.Java Program to Swap Two values using third variable using temp variable

// Importing generic libraries

import java.util.*;

class GFG {

// Function to swap two numbers

// Using temporary variable

static void swapValuesUsingThirdVariable(int m, int n)

{

// Swapping the values

int temp = m;

m = n;

n = temp;

System.out.println("Value of m is " + m

Written for

Course

Document information

Uploaded on
September 7, 2023
Number of pages
6
Written in
2023/2024
Type
OTHER
Person
Unknown

Subjects

$3.49
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
yennawarsidharth

Get to know the seller

Seller avatar
yennawarsidharth
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions