Plz Provide correct program code for all questions.

Plz Provide correct program code for all questions.

  1. Write a program to find the difference between sum of the squares and the square of the sums of n numbers?

  2. Develop a program that accepts the area of a square and will calculate its perimeter.

  3. Develop the program calculateCylinderVolume., which accepts radius of a cylinder's base disk and its height and computes the volume of the cylinder.

  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.

  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.

  6. Develop the program calculateCylinderArea, which accepts radius of the cylinder's base disk and its height and computes surface area of the cylinder.

  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.

  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.

  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.

  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.

Mail me at [email protected] as soon as possible. Thanks.

View Answers

December 16, 2010 at 3:27 PM

Hi Friend,

Try the following code:

1)

import java.util.*;
class FindDifference 
{
    public static void main(String[] args) 
    {
        int sum=0,sum1=0,sum2=0;
        Scanner input=new Scanner(System.in);
        System.out.println("Enter value of n: ");
        int n=input.nextInt();
        for(int i=1;i<=n;i++){
            int sq=i*i;
            sum1+=sq;
        }
        //System.out.println(sum1);
        for(int i=1;i<=n;i++){
            sum+=i;
        }
        sum2=sum*sum;
        //System.out.println(sum2);
        int diff=0;
        if(sum1>sum2){
        diff=sum1-sum2;
        }
        else{
            diff=sum2-sum1;
        }
        System.out.println(diff);

    }
}

2)

   import java.util.*;
    import java.text.*;
    class  PerimeterOfSquare{
        public static void main(String[] args) 
        {
             DecimalFormat df = new DecimalFormat("##.00");
             Scanner input=new Scanner(System.in);
             System.out.println("Enter Area of Square:");
             double area=input.nextDouble();
             double side=Math.sqrt(area);
             System.out.println("Side of Square is: "+df.format(side));
             double perimeter=4*side;
             System.out.println("Perimeter of Square is: "+df.format(perimeter));

        }
    }

3)

import java.util.*;
import java.text.*;

class CalculateCyliderVolume
{
    public static void main(String[] args) 
    {   
        DecimalFormat df = new DecimalFormat("##.00");
        double PI=3.14;
        Scanner input=new Scanner(System.in);
        System.out.print("Enter Radius: ");
        double r=input.nextDouble();

        System.out.print("Enter Height: ");
        double h=input.nextDouble();

        double volume=PI*r*r*h;
        System.out.println("Volume of Cylinder: "+df.format(volume));
        }
}

December 16, 2010 at 4:12 PM

continue..

4)

import java.util.*;
import java.text.*;
public class CalculateNetPay
{
    public static void main(String[]args){
    double taxRate=0.15;
    double hourlyRate=12;
    DecimalFormat df=new DecimalFormat("$##.00");
    Scanner input=new Scanner(System.in);
    System.out.print("Enter Number of Hours Worked: ");
    double hrs=input.nextDouble();
    double gp=hrs*hourlyRate;
    double tax=gp*taxRate;
    double netpay=gp-tax;
    System.out.println("Net Pay is: "+df.format(netpay));
    }
}

5)

import java.util.*;
import java.text.*;
class  CalculateTotalProfit{
    public static void main(String[] args) 
    {
        DecimalFormat df=new DecimalFormat("$##.00");
        double theaterCost=20;
        Scanner input=new Scanner(System.in);
        System.out.println("Enter Number of Customers: ");
        double cus=input.nextDouble();
        double earnFromTickets=5*cus;
        double attendeesCost=cus*0.50;
        double cost=attendeesCost+theaterCost;
        double profit=earnFromTickets-cost;
        System.out.println("Total Profit: "+df.format(profit));
    }
}

6)

import java.util.*;
import java.text.*;
class CalculateCylinderArea 
{
    public static void main(String[] args) 
    {
        DecimalFormat df = new DecimalFormat("##.00");
        double pi=3.14;
        Scanner input=new Scanner(System.in);
        System.out.print("Enter Radius: ");
        double r=input.nextDouble();

        System.out.print("Enter Height: ");
        double h=input.nextDouble();

        double v1=2*pi*r*r;
        double v2=2*pi*r*h;

        double surfaceArea=v1+v2;
        System.out.println("Surface Area of Cylinder: "+df.format(surfaceArea));
       }
}

Thanks


December 16, 2010 at 5:54 PM

Hi Friend,

Try the following code:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
class TotalInterest extends JFrame{
        TotalInterest(){
        JLabel lab1=new JLabel("Principal");
        final JTextField text1=new JTextField(20);

        JLabel lab2=new JLabel("Rate of Interest");
        final JTextField text2= new JTextField(20);

        JLabel lab3=new JLabel("Number of Months");
        final JTextField text3=new JTextField(20);

        JButton b=new JButton("Get");
        b.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
            double p=Double.parseDouble(text1.getText());
            double r=Double.parseDouble(text2.getText())/100;
            double t=Double.parseDouble(text3.getText())/12;

            double interest=p*r*t;
            JOptionPane.showMessageDialog(null, "Total Interest is: "+interest);
            }
        });
           setLayout(null);
           lab1.setBounds(10,10,100,20);
           text1.setBounds(150,10,200,20);
           lab2.setBounds(10,40,100,20);
           text2.setBounds(150,40,200,20);
           lab3.setBounds(10,70,120,20);
           text3.setBounds(150,70,200,20);
           b.setBounds(150,110,70,20);
           add(lab1);
           add(text1);
           add(lab2);
           add(text2);
           add(lab3);
           add(text3);
           add(b);
           setVisible(true);
           setSize(400,200);
        }
    public static void main(String[] args){
    new TotalInterest();
        }
}

Thanks


December 16, 2010 at 6:53 PM

this is not fair... this is your 1st assignment of TCS and u r searching answeres here n there...this will not help u... it's very basic assignment and try urself... its not compulsory to submit assignment... if u'll not learn this u'll really face the big problems.

Now its ur choice what do u want... getting some help n searching for all solutions r 2 diff things... so study... dont waste ur time..

Ads









Related Tutorials/Questions & Answers:
Plz Provide correct program code for all questions.
Plz Provide correct program code for all questions.   Write a program... of n numbers? Develop a program that accepts the area of a square and will calculate its perimeter. Develop the program calculateCylinderVolume., which accepts
Plz provide me all the material for Java
Plz provide me all the material for Java  Plz provide me all the material for Java   Please go through the following link: Java Tutorials
Advertisements
I didn't gat an output for this code, plz send me a correct code
I didn't gat an output for this code, plz send me a correct code  Hi, Here is my code: import java.awt.event.*; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.*; import java.sql.*; public
Please provide the java code for the given program.
Please provide the java code for the given program.   We need an application for managing an educational institute. That application should provide...: StudentAddr: StudentDob: Email: Course ALL Java C C++ Oracle Fees: Duration: Faculty
plz Help me find the correct programs answers
plz Help me find the correct programs answers   Create a washing... and loading capacity. Display the updated truck details. Write a program which performs to raise a number to a power and returns the value. Provide a behavior
Please provide the code
Please provide the code   Program to find depth of the file in a directory and list all files those are having more number of parent directories
plz send code for this
plz send code for this  Program to calculate the sum of two big numbers (the numbers can contain more than 1000 digits). Don't use any library classes or methods (BigInteger etc
Provide the code please
Provide the code please   Program to calculate the sum of two big numbers (the numbers can contain more than 1000 digits). Don't use any library classes or methods (BigInteger etc
please correct this program
please correct this program  import java.util.Scanner; public class Nam { public static void main (String arg[]) { String[] name={"Aki","Karthi","Tk","Suba","Malu","Buvi","Janu","Sara","Sandy","Abi","Ani","Amu
Please provide the code
Please provide the code   Write a program to recursively download the web pages available in the given site URL
Plz give me code for this question
Plz give me code for this question  Program to find depth of the file in a directory and list all files those are having more number of parent directories
please provide the code
please provide the code   Develop a multi-client chat application
Please provide the code
Please provide the code   Create a file system: We just have one file on the hard disk. But we can create directories, sub-directories and files in that file only
multiple choice questions program
multiple choice questions program  how can i implement the program to store 10 multiple choice questions in one class to develop a oneline quiz with using java language
multiple choice questions program
multiple choice questions program  how can i implement the program to store 10 multiple choice questions in one class to develop a oneline quiz with using java language
plz help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
what error in this program plese correct it
what error in this program plese correct it  import java.io.*; class y { public static void main (String args[]) { Data inputStream dis = new Data inputstream(System.in); float l,b,a; Systyem.out.println("enter the lengh"); l
jsp code plz
jsp code plz  write jsp code which takes student roll number as input and prints the student group,study center, and his grade card   Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml
Is the logic correct to detect IE version..plz let me know
Is the logic correct to detect IE version..plz let me know  <html> <head> <script type="text/javascript"> function checkIEVersion() { var IE_Version; var IE_Engine; /*@cc_on @if( @_jscript_version
code for program
code for program  hello,I am new to java and need to get the code for a program,i've been trying all sorts of code and nothing works any help would be appreciated.Below is what the program should output with the user's input
program code
program code  I need to get the code for the following,the user's input are enclosed in curly brackets,thank you. HARDWARE ITEMS CODE DESCRIPTION... 23} ADDRESS-2: {Building 8} ADDRESS-3: {Winchester} POST CODE: {89763} ENTER
code for a program
code for a program   Write a program which has 2 numbers. There should be an option to add, multiply, divide and subtract these numbers a. If user opts "A" - Add the 2 numbers b. If user opts "S" - Subtract the numbers c
plz check my codings are correct or not...There is an error..i cant find it..
plz check my codings are correct or not...There is an error..i cant find it..  import java.util.Scanner; public class Student { private String indexNo; private String gender; private char initial; private int mark1
program code
program code  I want a program that accepts a word from TextField and check with multiple .csv file and displays the snippets from csv file into TextArea. Please help me
program code
program code  login and registration form for shopping cart using struts-hibernate with oracle database connection
swing program plz urgent sir - Java Beginners
swing program plz urgent sir   hi sir,i waan a jtable swings program table having column names "itemid","price".Initially table having single empty row.whenever we click the "enter" button automatically new row will be insert
PLZ HELP ME. i need php code.
PLZ HELP ME. i need php code.   I want php code for bellow OUTPUT. output is just example but it must be letters only. abc bcd efg jku rgt azs hje qqc wws adt
sir plz send the project on quiz system code
sir plz send the project on quiz system code  sir plz send the client server based project in core java database in my sql
full description of program code
(consonants)); } } above a program code of reverse string program in this program.... i've a problem that plz describe me full description of this code thanks...full description of program code  import java.util.*; class
php brute force code.. hlp plz .....
php brute force code.. hlp plz .....  hello friends, from somewhere i got a code that can generate all posible combination via recursive function in php all is working fine, but for my project i need a more more additional
Please provide jquery inline form validation for the code
Please provide jquery inline form validation for the code   <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Student Form</title> <script type

Ads