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

    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
  • 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
  • Good Essays

    unit 8 homework

    • 793 Words
    • 5 Pages

    4. Design a loop that asks the user to enter a number. The loop should iterate 10 times and keep a running total of the numbers entered.…

    • 793 Words
    • 5 Pages
    Good 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
  • Better Essays

    Human Factors Hmwk 2

    • 1098 Words
    • 5 Pages

    4. Consider the task of using a calculator . (10 points) What would be an example of a:…

    • 1098 Words
    • 5 Pages
    Better 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
  • 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
  • Satisfactory Essays

    memory system

    • 5335 Words
    • 22 Pages

    loop. The general structure of the program is given in Figure P5.1. The decimal memory…

    • 5335 Words
    • 22 Pages
    Satisfactory 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