SOURCE CODE #1
//A simple program to find the sum of all natural numbers till 100 (0,100)
public class SumTillHundred
{
public static void main(String args[])
{
int i;
int digit;
for (i=1 , digit = 0; i<=100;i++)
{
digit=digit+i;
}
System.out.println("The sum of natural numbers till 100 = " + digit);
}
}
//A simple program to find the sum of all natural numbers till 100 (0,100)
public class SumTillHundred
{
public static void main(String args[])
{
int i;
int digit;
for (i=1 , digit = 0; i<=100;i++)
{
digit=digit+i;
}
System.out.println("The sum of natural numbers till 100 = " + digit);
}
}
OUTPUT FOR SOURCE CODE #1
The sum of natural numbers till 100 = 5050
SOURCE CODE #2
//A simple program to find the product of all even positive numbers less than ten
public class ProdEvenLessThanTen
{
public static void main(String args[])
{
int n;
int digit=1;
for(n=2;n<10 n="" p="">10>
if(n%2==0)
digit=digit*n;
System.out.println("The product of all even numbers less than 10 is " + digit);
}
}
OUTPUT FOR SOURCE CODE #2
The product of all even numbers less than 10 is 384
SOURCE CODE #3
//A Simple java program that reads a line from keyboard and outputs "Hello"+name
import java.io.*;
public class HelloPlusName
{
public static void main(String args[]) throws java.lang.Exception
{
System.out.println("Enter your name");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String name = br.readLine();
System.out.println("Hello " + name);
}
}
OUTPUT FOR SOURCE CODE #3
Enter your name
Hemapriya
Hello Hemapriya
SOURCE CODE #4
//A simple program that appends firstname with surname and prints the output as "welcome + fullname"
import java.io.*;
import java.lang.String;
public class SurnamePlusFirstname {
public static void main (String args[])throws Exception
{
System.out.println("Enter your firstname \n");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String firstname = br.readLine();
System.out.println("Enter your surname \n");
BufferedReader br2 = new BufferedReader(new InputStreamReader(System.in));
String lastname = br2.readLine();
StringBuilder fullname = new StringBuilder();
fullname.append(firstname);
fullname.append(lastname);
System.out.println("Welcome " + fullname + "!");
}
}
OUTPUT FOR SOURCE CODE #4
Enter your firstname
Hemapriya
Enter your surname
Gopal
Welcome HemapriyaGopal!
SOURCE CODE #5
//Program to find the slope of a straight line in XY- axes when the equation is given
//Assumption: THE SIMPLE CASE THAT THE STRAIGHT LINE INTERSECTS BOTH THE AXES
import java.io.*;
public class SlopeOfStraightLine {
public static void main(String args[]) throws Exception
{
System.out.println("Enter the equation of the straight line in the two dimensional axes");
BufferedReader br = new BufferedReader(new InputStreamReader (System.in));
String eqn = br.readLine();
System.out.println("Enter the co-efficient of x \n");
BufferedReader br1 = new BufferedReader(new InputStreamReader (System.in));
String str1 = br1.readLine();
float coex = Integer.parseInt(str1);
System.out.println("Enter the co-efficient of y \n");
BufferedReader br2 = new BufferedReader(new InputStreamReader (System.in));
String str2 = br2.readLine();
float coey = Integer.parseInt(str2);
float slope = -(coey/coex);
System.out.println("The straight line having the equation " + eqn + " has the slope value of " + slope + "\n");
}
}
OUTPUT FOR SOURCE CODE #5
Enter the equation of the straight line in the two dimensional axes
2X-3Y+6=0
Enter the co-efficient of x
2
Enter the co-efficient of y
-3
The straight line having the equation 2X-3Y+6=0 has the slope value of 1.5
Under SOURCE CODE #2
ReplyDeleteLINE NUMBER-->8
for(n=2;n<10;n++)
/* There is some problem with the page's HTML coding that is disrupting the source code, I tried to fix it, but I am not able to. I deeply apologise for the inconvenience caused*/
Play Blackjack Online for Real Money at the JTM Hub
ReplyDeleteBlackjack is a fast-paced casino game, 목포 출장마사지 and players can now 영천 출장안마 play with 경기도 출장마사지 real dealers 서울특별 출장샵 in traditional casino slots or 세종특별자치 출장마사지 online blackjack tables with