Preview

Java assignments

Satisfactory Essays
Open Document
Open Document
272 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Java assignments
Assignment Day 1

1. Write a program to print “Hello Java” (enclosed within double quotes) on the standard output.
2. Write a Java program that calculates and prints the simple interest using the formula :
Simple Interest = PTR / 100 input values P,T,R should be accepted as command line input as below.
e.g. java Simple Interest 5 10 15
3. Write a program to compute sum of digits of a given number.
(Hint: Separate digits one by one from the number and then add)
4. Write a program that prints prime numbers between 1 to n. Number n should be accepted as command line input
5. Write a program that converts a decimal number to Roman number. Decimal Number is accepted as command line input at the time of execution.
6. WAP to to print following pattern (Pascals Triangle)

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
7. Write a Java program that accepts the radius of a circle and displays the options as follows :
1. find diameter of a cicle.(2* radius)
2. find area of circle.( _ * radius * radius)
3. find circumference of a circle.( 2 * _ * radius)
4. exit.
Use case statement to implement each option and display the corresponding output. 8. Define a class called fruit with the following attributes :
1. Name of the fruit.
2. Single fruit or bunch fruit.
3. Price.
Define a suitable constructor and displayFruit() method that displays values of all the attributes. Write a program that creates 2 objects of fruit class and display their attributes.
9. Write a program to find the Factorial of a number using Recursion. Factorial can be defined as Factorial(n) = 1 * 2 * 3 ….* (n-1) * n.

10. WAP to print the sum of Harmonic Series: Input=3
Output=1/1+1/2+1/3=1.83333333..

11. WAP to display the following output 1 2 4 3 6 9
4 8 12 16
5 10 15 20 25

12. WAP to display the entered number in word. Input: 123 Output: One Two Three

You May Also Find These Documents Helpful

  • Satisfactory Essays

    = z) return true; else return false; } Problem 5 a. Output: 720 b. Output: 0 c. Output: 71 d. Output: 362880 Problem 6 a. Output: “Take Programming I.” b. Output:…

    • 188 Words
    • 1 Page
    Satisfactory Essays
  • Satisfactory Essays

    PT1420 Chapter 3 Review

    • 1062 Words
    • 8 Pages

    3. Write assignment statements that perform the following operations with the variables a, b, and c.…

    • 1062 Words
    • 8 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Due Date: February 20, 2012 by 5:00pm. ABSOLUTELY NO LATE ASSIGNMENTS Instructions: Complete the question below in pairs. Please note that your code should contain proper comments.…

    • 703 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    5.) Write the pseudocode for a program that will determine the average miles per gallon a car gets. (Inputs should be miles driven and gallons of gas used)…

    • 453 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    This lab was testing different methods to prevent bean beetles form infesting a chickpea harvest. They wanted to find something that would protect the crop from this invasive creature. To do this they created 3 replicate experiments which contained 25g of seeds each group with a different genotype, and 5 newly hatched adult C. maculatus were added to the jar. They continued to check this on a weekly basis, at the end of the experiment they found that the results where quite different for each jar, and that all of them were not immune to the bean beetle.…

    • 524 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    Mat 540 Week 4 Paper

    • 1775 Words
    • 8 Pages

    * Provide a set of values that will test the normal operation of this program segment. Defend your choices.…

    • 1775 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    It210 Appendix F

    • 372 Words
    • 3 Pages

    5. The program will allow the user to clear all the input fields and do the calculations over.…

    • 372 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    unit 3

    • 313 Words
    • 2 Pages

    9. Write a pseudocode statement that subtracts the variable Down Payment from the variable total and assigns the result to the variable due.…

    • 313 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Comp122 Week 2 Homework

    • 301 Words
    • 2 Pages

    4. Write a C++ statement that uses the manipulator 'setfill' to output a line containing 35 asterisk characters.…

    • 301 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    UNIT 2

    • 470 Words
    • 3 Pages

    5.) Write the pseudocode for a program that will determine the average miles per gallon a car gets. (Inputs should be miles driven and gallons of gas used)…

    • 470 Words
    • 3 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Add a further field, of your choosing, to the Track class, and provide accessor and mutator methods to query and manipulate it. Find a way to use this information in your version of the project; for instance, include it in a track’s details string, or allow it to be set via a method in the MusicOrganizer class.…

    • 341 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    1. Mr. Dubey borrows Rs 1,00,000 from State Bank of India at 11% per annum compound interest. He repays Rs 41,000 at the end of first year and Rs 47,700 at the end of the second year. Find the amount outstanding at the beginning of the third year. 2. What sum of money will amount to Rs 9261 in 3 years at 5% per annum compound interest? 3. The simple interest on a sum of money for 2 years at 4% per annum is Rs 340. Find (i) the sum of money and (ii) the compound interest on this sum for one year payable half yearly at the same rate. 4. Ramesh invests Rs 12800 for three years at the rate of 10% per annum compound interest. Find : (i) The sum due to Ramesh at the end of the first year. (ii) The interest he earns for the second year. (iii) The total amount due to him at the end of the third year. 5. A person invests Rs 10,000 for two years at a certain rate of interest compounded annually. At the end of one year this sum amounts to Rs 12,000. Calculate : (i) the rate of interest per annum (ii) the amount at the end of the second year. 6. If the interest is compounded half yearly, calculate the amount when the principal is Rs 7400, the rate of interest is 5% per annum and the duration is one year. 7. The compound interest on a certain sum of money at 5% per annum for 2 years is Rs 246. Calculate the simple interest on the same sum for three years at 6% per annum. 8. What sum of money will amount to Rs 3630 in two years at 10% p.a. compound interest? 9. On a certain sum of money, the difference between the compound interest for a year, payable half-yearly, and the simple interest for a year is Rs 180. Find the sum lent out, if the rate of interest in both the cases is 10% p.a. 10. A man borrows Rs 5000 at 12% compound interest p.a., interest payable every six months. He pays back Rs 1800 at the end of every six months. Calculate the third payment he had to make at the end of 18 months in order to clear the entire loan. 11. Calculate the…

    • 2380 Words
    • 10 Pages
    Good Essays
  • Good Essays

    Char D1

    • 599 Words
    • 3 Pages

    void AcknowledgeCall (char &d1, char &d2, char &d3, char &d4, char &d5, char &d6, char &d7, char &d8);…

    • 599 Words
    • 3 Pages
    Good Essays
  • Good Essays

    1) Simple Interest: Simple interest is the most basic type of interest. In order to understand how various types of transactions work, it helps to have a complete understanding of simple interest. The simple interest formula is used to calculate the interest accrued on a loan or savings account that has simple interest. The simple interest formula is fairly simple to compute and to remember as principal time’s rate times time. An example of a simple interest calculation would be a 3 year saving account at a 10% rate with an original balance of TK 10,000. By inputting these variables into the formula, TK. 10,000 times 10% times 3 years would be TK 3000. The formula of simple interest is:…

    • 3705 Words
    • 15 Pages
    Good Essays
  • Better Essays

    Expression – represents a computation involving values, variables, and operations that together evaluate a value system.out.println(++i);…

    • 2088 Words
    • 9 Pages
    Better Essays