Java Ideas: Last Posts
Java Ideas: Last Posts
HOME
MOBILE
MAKE HOME
INVITE A FRIEND
ADD TO FAVORITE
Last posts
PC EX1 updated 1.50pm important study material links for java class diagram Find the number of occurrences of given word in a sentence. Find the number of occurrences of digit 1 in a number.
Most Score
PC EX1 updated 1.50pm class diagram important study material links for java Find the number of occurrences of given word in a sentence. Find the number of occurrences of digit 1 in a number.
Categories
Uncategorized LEVEL TWO LEVEL ONE
Archives
January 2011
Daily links
Top of Form
Search
Bottom of Form
Ads
Immigration To Canada Canada has many faces. It is a trading nation-one of the world's richest markets, multicultural-a country that encourages immigration.
www.lastsee.com
Platted Hairstyles For Men The basic purpose of any hairstyle should be to add liveliness and create an effect that will accentuate your best features.
www.lastsee.com
Platted Hairstyles For Women The basic purpose of any hairstyle should be to add liveliness and create an effect that will accentuate your best features.
www.lastsee.com
Revo Sunglasses For Women Considering your skin can turn pink when you spend too much time in the sun, imagine the damage the sun's ultraviolet (UV) rays can do to your eyes.
www.lastsee.com
Meta
Site Admin Template RSS
Blogroll
javaidea.blogoak.com javaidea.lastsee.com javaidea.soonin.com javaidea.blognee.com javaidea.blogree.com javaidea.bloghee.com javaidea.blogtee.com javaidea.blogwee.com
Posted by Karti on January 1, 2011 1. Write a program to find the difference between sum of the squares and the square of the sums of n numbers?
import java.io.*;
import java.util.Scanner;
class DiffSumSqu
int n=s.nextInt();
int SumSqua=((n^3)/3)+((n^2)/2)+(n/6);
int sum = 0;
diff = SumSqua-SquaSum;
System.out.println("Difference between sum of the squares and the square of the sum of given
"+n);
System.out.println("");
Output:
Difference between sum of the squares and the square of the sum of given 5 numbers is : 3328
____________________________________________________________
2) Develop a program that accepts the area of a square and will calculate its perimeter.
import java.io.*;
import java.util.Scanner;
class AreaPeri
double Area=s.nextDouble();
double Perimeter=4*Math.sqrt(Area);
System.out.println("");
Output:
Area of Square :
16
___________________________________________________
3)Develop the program calculateCylinderVolume., which accepts radius of a cylinder's base disk and its height and computes the volume of the cylinder.
import java.io.*;
import java.util.Scanner;
class CalculateCylinderVolume
double rad=s.nextDouble();
double ht=s.nextDouble();
double vol=Math.PI*rad*rad*ht;
System.out.println("");
Output :
_____________________________________________________
4)Utopias tax accountants always use programs that compute income taxes even though the tax rate is a solid, never-changing 15%. Define the program calculateTax which determines the tax on the gross pay. Define calculateNetPay that determines the net pay of an employee from the number of hours worked. Assume an hourly rate of $12.
import java.io.*;
import java.util.Scanner;
class Utopias
int days=s.nextInt();
int hours=s.nextInt();
int ot=s.nextInt();
int l=s.nextInt();
double gross=((days*hours)+ot-l)*12;
double net=gross-tax;
System.out.println("");
Output :
300
50
10
5)An old-style movie theater has a simple profit program. Each customer pays $5 per ticket. Every performance costs the theater $20, plus $.50 per attendee. Develop the program calculateTotalProfit that consumes the number of attendees (of a show) and calculates how much income the show earns
class calculateTotalProfit
int n=s.nextInt();
System.out.println("");
Output :
100
6)Develop the program calculateCylinderArea, which accepts radius of the cylinder's base disk and its height and computes surface area of the cylinder.
import java.io.*;
import java.util.Scanner;
class calculateCylinderArea
double rad=s.nextDouble();
double ht=s.nextDouble();
double area=2*Math.PI*rad*(rad+ht);
System.out.println("");
Output :
7)Develop the program calculatePipeArea. It computes the surface area of a pipe, which is an open cylinder. The program accpets three values: the pipes inner radius, its length, and the thickness of its wall.
import java.io.*;
import java.util.Scanner;
class calculatePipeArea
double radius=s.nextDouble();
double length=s.nextDouble();
double thick=s.nextDouble();
double area=2*Math.PI*(radius+thick)*lenght;
System.out.println("");
Output :
8)Develop the program calculateHeight, which computes the height that a rocket reaches in a given amount of time. If the rocket accelerates at a constant rate g, it reaches a speed of g t in t time units and a height of 1/2 * v * t where v is the speed at t.
import java.io.*;
import java.util.Scanner;
class calculateHeight
double t=s.nextDouble();
double v=9.8*t;
double height=0.5*v*t;
System.out.println("");
Output :
100
9)Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean Theorem is c2 = a2 + b2.
import java.io.*;
import java.util.Scanner;
class BoatDistance
double rw=s.nextDouble();
double rs=s.nextDouble();
double bs=s.nextDouble();
double time=rw/bs; //time takes to travel from shore to shore straight by the boat double w2=time*rs; //distance due to down stream
double bd=Math.sqrt((rw*rw)+(w2*w2));
System.out.println("");
Output :
80
10)Develop a program that accepts an initial amount of money (called the principal), a simple annual interest rate, and a number of months will compute the balance at the end of that time. Assume that no additional deposits or withdrawals are made and that a month is 1/12 of a year. Total interest is the product of the principal, the annual interest rate expressed as a decimal, and the number of years.
import java.io.*;
import java.util.Scanner;
class calculateBalance
double p=s.nextDouble();
double r=s.nextDouble();
double m=s.nextDouble();
double si=(p*(m/12)*r)/100;
double bal=p+si;
System.out.println("");
Output :
10000
6.5
Tags : java 1 Comments for JAVA EXAMPLES ONE : Wed 20 Jul 2011 20:18 rose Wrote :
nice work....!!
Your name :
Reset
Bottom of Form
Older Posts
Pages : Next page - Random page - Previous page
Blog Labels
find - addition - think - ex1 - java - the - important - class