This action might not be possible to undo. Are you sure you want to continue?
Write a java Appletto display your age. 3. Write a program that calculates and printsthe product ofthree integers. 4. Write a program that converts a Fahrenheit degree to Celsius using the formula: 5. Write an application that displaysthe numbers 1 to 4 on the same line, with each pair of adjacent numbers separated by one space. Write the application using the following techniques: a. Use one System.out.println statement. b. Use four System.out.printstatements. c. Use one System. out. printfstatement. 6. Write an application that asksthe userto entertwo integers, obtainsthem from the user and printstheirsum, product, difference and quotient(division). CHAPTER 3 7. Write an application that asksthe userto entertwo integers, obtainsthem from the user and displaysthe larger numberfollowed by the words “islarger”. Ifthe numbers are equal, print “These numbers are equal” 8. Write an application thatinputsthree integersfrom the user and displaysthe sum, average, product,smallest and largest ofthe numbers. 9. Write an application thatreadstwo integers, determines whetherthe firstis a multiple ofthe second and print the result.[HintUse the remainder operator.] 10. The process offinding the largest value (i.e.,the maximum of a group of values)is used frequently in computer
For example. 11. Stop the loop by typing in ‐1. f. number: The integermostrecently input by the user. Write a Java application that allowsthe userto enter up to 20 integer gradesinto an array.the outputwill be “HELLOhello" 15. If. Setthe 10 elements ofinteger array countsto zero.the string “Hello" is given. Write statementsthat perform the following one‐dimensional‐array operations: d. c.forinstance. Write a Java program thatreads a string from the keyboard. and call method sphereVolumeto calculate and display the volume ofthe sphere. Write a complete Java application to promptthe userforthe double radius of a sphere. e. a program that determinesthe winner of a sales contest would inputthe number of unitssold by each sales person.first all uppercase and next all lowercase. counter:A counterto countto 10 (i. 14. Write a Java application that useslooping to printthe following table of values: 12.e. Display the five values ofinteger array bestScoresin column format. Your program should use atleastthe following three variables: a. Add one to each ofthe 15 elements ofinteger array bonus.to keep track of howmany numbers have been input and to determine when all 10 numbers have been processed). b. largest: The largest numberfound so far.Write a Java application thatinputs a series of 10 integers and determines and printsthe largestinteger. The sales person who sellsthe most units winsthe contest.Use the following statementto calculate the volume: CHAPTER 4 13. Your main method should call an Average method thatreturnsthe average ofthe grades.. and outputsthe string twice in a row.Use the .applications.
provide a method named getInvoice Amountthat calculatesthe invoice amount(i. Ifit does. Ifthe monthly salary is not positive.a quantity ofthe item being purchased (type int) and a price peritem (double). Provide a set and a get method for each instance variable. a last name (typeString) and a monthly salary (double).the balance should be left unchanged and the method should print a message indicating ―Debit amount exceeded account balance. In addition. Modify class AccountTest(intheexample)to test method debit.a part description(type String).Write a test application named EmployeeTestthat demonstrates class . itshould be setto 0. Ensure thatthe debit amount does not exceed theAccount’s balance.0.setitto 0.0.DecimalFormat classto formatthe average to 2 decimal places. multipliesthe quantity by the price peritem). CHAPTER 5 16.then returnsthe amount as a double value. Modify class Account(in the example)to provide a method called debitthat withdraws money froman Account.Write a test application named InvoiceTestthat demonstrates classInvoice’s capabilities. Ifthe price peritem is not positive. 17. Your classshould have a constructorthatinitializesthe fourinstance variables. Create a class called Invoice that a hardware store might use to represent an invoice for an item sold atthe store.e. Your classshould have a constructorthat initializesthe three instance variables.. Ifthe quantity is not positive. Provide a set and a get method for each instance variable. 18. itshould be setto 0. An Invoice should include four pieces ofinformation asinstance variables‐a part number(type String). Create a class called Employee thatincludesthree pieces ofinformation asinstance variables—a first name (typeString).
Then setthe annualInterestRate to 5%.Usea static variable annualInterestRate to store the annual interestrate for all account holders. Provide a static method modifyInterestRate thatsetsthe annualInterestRate to a new value.saver1 and saver2. Set annualInterestRate to 4%. 19. Write a test application namedDateTestthat demonstrates classDate’s capabilities. Provide a method displayDate that displaysthe month. calculate the next month’sinterest and printthe new balancesfor both savers. Your classshould have a constructorthatinitializesthe three instance variables and assumesthatthe values provided are correct.Employee’s capabilities. Provide a set and a get method for each instance variable. a day (typeint) and a year(typeint). Create a class called Book to represent a book. Then give each Employee a 10% raise and display each Employee’s yearly salary again. 21. Create two Employee objects and display each object’s yearly salary.respectively.oumstudents. Each object ofthe class contains a private instance variable savingsBalance indicating the amountthe saver currently has ondeposit.00 and $3000. Provide method calculateMonthlyInterestto calculate the monthlywww.00.then calculate the monthly interest and printthe newbalancesfor both savers.tk interest by multiplying the savingsBalance by annualInterestRate divided by 12 thisinterestshould be added to savingsBalance. Instantiate two savingsAccount objects.with balances of $2000. CHAPTER 6 20. Create a class calledDate thatincludesthree pieces ofinformation asinstance variables—a month (typeint). Write a program to test class SavingsAccount. day and yearseparated by forward slashes(/). Create class SavingsAccount.A Book should include four pieces ofinformation asinstance .
◦intspeed.variables‐a book name. Inaddition. Create a super class called Car. ◦doubleregularPrice. c. a.Otherwise. Create a sub class of Car class and name it as Truck.subtractthemanufacturerDiscount. d. Create a subclass of Car class and name it as Ford. b. ◦doublegetSalePrice(). Create a subclass of Car class and name it as Sedan. . The Car class hasthe following fields and methods. Your classshould have a constructor thatinitializesthe fourinstance variables. You should use this keyword in member methods and constructor.20%discount. CHAPTER 7 22. ◦doublegetSalePrice(). ◦Stringcolor. Write a test application named BookTestto create an array of objectfor 30 elementsfor class Book to demonstrate the class Book's capabilities. The Truck class hasthe following fields and methods. The Sedan class hasthe following fields and methods.//FromthesalepricecomputedfromCarclass.//Ifweight>2000. ◦intmanufacturerDiscount. an ISBNnumber. ◦doublegetSalePrice(). provide a method named getBookInfo thatreturnsthe description ofthe book as a String (the description should include allthe information aboutthe book).10%discount. an author name and a publisher. The Ford class hasthe following fields and methods ◦intyear. Provide a mutator method and accessor method (query method)for each instance variable. ◦intweight.
tk ◦Create an instance of Car class and initialize allthe fields with appropriate values.. Display the sale prices of all instance.) method in the constructorforinitializing the fields ofthe superclass.Use the techniquesshown in example..oumstudents.◦intlength. Create an appletthat can display the following component. CHAPTER 8 CHAPTER 9 23.) method in the constructorforinitializing the fields ofthe super class.Otherwise.Use super(.//Iflength>20feet. ◦doublegetSalePrice().10%discount. Write an appletthat asksthe userto entertwo floating‐point numbers.www. ◦Create two instances ofthe Ford class and initialize allthe fields with appropriate values. Create MyOwnAutoShop class which containsthe main() method. The Fahrenheittemperature .No event handling is needed forthe components. obtainsthe two numbersfrom the user and drawstheirsum.. Create an appletthat can display the following component. e.5%discount.. CHAPTER 10 24. Temperature Conversion a. Write a temperature conversion appletthat convertsfromFahrenheitto Celsius. Perform the following within the main() method.No event handling is needed forthe components. 25. product(multiplication). CHAPTER 11 26.Use super(. ◦Create an instance of Sedan class and initialize allthe fields with appropriate values. difference and quotient(division).
The appletshould also allow the usertomake conversions between any two scales.Use the following formula forthe conversion: Celcius = ((5/9)*(Ferenheit‐32)).Use the following formula forthe conversion between Kelvin and Celsius(in addition to the formulainQ1): Kelvin = Celcius + 273. Enhance the temperature conversion applet ofQ1 by adding the Kelvin temperature scale.should be entered fromthe keyboard (via a JTextField). A JLabelshould be used to display the converted temperature.15 . b.
This action might not be possible to undo. Are you sure you want to continue?
We've moved you to where you read on your other device.
Get the full title to continue reading from where you left off, or restart the preview.