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..









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
plz solve this program - Java Interview Questions
plz solve this program  write a program to out put this resault using two dimensional array this is an image of the reasult: http://www.4shared.com/file/154846107/dc2f1ac1/_2__Untitled-1.html so help me
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
very urgent : Iam unable to code this program plz help me - RMI
very urgent : Iam unable to code this program plz help me  Write a Multi-user chat server and client.  Hi friend, Chat server is a standlone application that is made up the combination of two-application, server
program code - Java Server Faces Questions
program code  hai i am meyis i need a jsp program code for date generation.(mssql-back end) Fields are fromdate and todate both field are datetime..., Plz explain the below code line with source code to solve the problem. "how
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 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   Program to find depth of the file in a directory and list all files those are having more number of parent directories
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
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 me the program for that ques.
provide me the program for that ques.  wtite a program in java there is a class readchar.the functionality of this class is to read a string from...;Hi Friend, You can try the following code:ADS_TO_REPLACE_1 import java.util.
Please provide the code
Please provide the code   Write a program to recursively download the web pages available in the given site URL
please provide the code
please provide the code   Develop a multi-client chat application
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   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
provide code - Swing AWT
provide code  Dear frnds please provide code for two player CHESS GAME.....using swings,awt concepts   Hi friend, import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; public
plz - Java Interview Questions
; Hi Friend, Try the following code: import java.util.*; class die
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
plz help me today plz plz - Java Interview Questions
plz help me today plz plz  2.) Suppose list is an array of six elements of type int. What is stored in list after the following java code executes....) What is the output of the following program? . public class exercise6
plz help me find a program
plz help me find a program  plz help..i want a source code in jsp for order processing
please provide code - Java Beginners
please provide code  provide code to snake game in J2SE
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
provide me code - Java Beginners
provide me code  can any body provide code for SNAKE XENZIA game in NOKIA mobile? please urgently
plz help - Java Interview Questions
plz help  1)write a java program that prompts the user to input... on three exams and two large projects.the program should then add five decimal... don't use "for"  Hi Friend, Try the following code 1) import
help plz - Java Interview Questions
help plz  1 )write a program that does the following : a. prompts... 2)write a program that prompts the user to input a four-digit positive integer. the program than outputs the digits of the number, one digit per line
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
help plz - Java Interview Questions
help plz   1 )write a program that does the following : a. prompts... 2)write a program that prompts the user to input a four-digit positive integer. the program than outputs the digits of the number, one digit per line
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
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
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
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
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
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
help today plz:( - Java Interview Questions
help today plz:(  write a program that promptes the user to enter the weight of a package in pounds, and then outputs the weight of the backage... "for" and import java.text.*;  Hi Friend, Try the following code
Plz give the answers - Java Interview Questions
), is the number itself. Write a JAVA program to find all perfect numbers between 2...Plz give the answers  1.Computing cos(x) using the cosine series: Recall that cos(x) is given by the following series: Write a program to compute
Plz help me in writing the code - Java Beginners
Plz help me in writing the code   Write a two user Chess Game. (users must be on different systems
Plz help me in writing the code - Java Beginners
Plz help me in writing the code   Write a two user Chess Game. (users must be on different systems
help me plz - Java Interview Questions
? plz answer my question   Hi Friend, Try the following code: 1...help me plz  1)write a java program that prompts the user to input... scors on three exams and two large projects.the program should then add five
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
can u plz try this program - Java Beginners
can u plz try this program  Write a small record management...) No database should be used. All data must be stored in one or two files. Listing... operation. Thanks in advance   Hi friend, form code
provide code in servlets,javascript,jsp - JavaMail
provide code in servlets,javascript,jsp  i create mail like fallowing... radiobutton automatically. So frnds please understand my problem urgently provide... hope that, this link will help you. if you have any problem then send me code
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
plz explain me the output of program - Java Beginners
plz explain me the output of program  Hi friends, can u please explain me the output of below program with proper explanation of each and every line...;Hi Friend, Output of this program is: a=2 b=0 c=0 mul=27 volume=18
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
plz help me - Java Interview Questions
plz help me  1)Rewrite the method in exercise 10 such that it use the binary search algorithm instead. the linear search algorithm is suitable for small arrays or unsorted arrays. for large arrays linear search is inefficient
power program - Java Interview Questions
power program  I want program of 2 to the power of 0 and 2 to the power of 1 like that i want source code plz help

Ads