Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes
Create a calculator class which will have methods add, multiply, divide & subtract
Create a class called Student which has the following methods:
i. Average: which would accept marks of 3 examinations & return whether the student has passed or failed depending on whether he has scored an average above 50 or not.
ii. Inputname: which would accept the name of the student & returns the name.
Create a Bank class with methods deposit & withdraw. The deposit method would accept attributes amount & balance & returns the new balance which is the sum of amount & balance. Similarly, the withdraw method would accept the attributes amount & balance & returns the new balance ?balance ? amount? if balance > = amount or return 0 otherwise.
Create an Employee class which has methods netSalary which would accept salary & tax as arguments & returns the netSalary which is tax deducted from the salary. Also it has a method grade which would accept the grade of the employee & return grade.
Create Product having following attributes: Product ID, Name, Category ID and UnitPrice. Create ElectricalProduct having the following additional attributes: VoltageRange and Wattage. Add a behavior to change the Wattage and price of the electrical product. Display the updated ElectricalProduct details.
Create Book having following attributes: Book ID, Title, Author and Price. Create Periodical which has the following additional attributes: Period (weekly, monthly etc...) .Add a behavior to modify the Price and the Period of the periodical. Display the updated periodical details.
Create Vehicle having following attributes: Vehicle No., Model, Manufacturer and Color. Create truck which has the following additional attributes:loading capacity( 100 tons?).Add a behavior to change the color 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 to the program so as to accept any type of numeric values and returns the results.
Write a function Model-of-Category for a Tata motor dealers, which accepts category of car customer is looking for and returns the car Model available in that category. the function should accept the following categories "SUV", "SEDAN", "ECONOMY", and "MINI" which in turn returns "TATA SAFARI" , "TATA INDIGO" , "TATA INDICA" and "TATA NANO" respectively.
Plz mail me your answers at [email protected]. Thanks........
package com;
import java.io.BufferedReader; import java.io.InputStreamReader;
/** * pote * @author pradeshs */
public class Student { public static void avg(int value1,int value2,int value_3,String name) { int output=(value1+value2+value_3)/3; // calculating average value for 3 subjects System.out.println("Average:::"+output); if(output>=50) // condition for checking whether the student has passed or failed { System.out.println("PASS"); System.out.println("Name of the student:"+name); // task 2- returns name } else { System.out.println("FAIL"); System.out.println("Name of the student:"+name); // task 2- returns name } } public static void main(String[] args) { int value1, value2,value_3; // local variables BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); try { System.out.println("\t\t Average::::::::"); System.out.println("Enter the your name :"); String name =in.readLine(); // Input value from keyboard for name // taken for the second task. System.out.println("Enter the First Subject Mark :"); value_1 = Integer.parseInt(in.readLine()); // Input value from keyboard for first value System.out.println("Enter the Second Subject Mark: "); value_2 = Integer.parseInt(in.readLine()); // Input value from keyboard for second value System.out.println("Enter the Third Subject Mark: "); value_3 = Integer.parseInt(in.readLine()); // Input value from keyboard for third value avg(value1,value2,value_3,name); } catch (Exception e) { System.out.println("Error:::" + e); } } }
package com;
import java.io.BufferedReader; import java.io.InputStreamReader;
/** * pote * @author pradeshs */ public class Bank {
static int output; // variables are defined at class level public static void deposit(int amount, int balance) // performs deposit calculation { output = amount + balance; } public static void withdraw(int amount, int balance) // performs withdraw calculation { output = balance - amount; if (balance >= amount) { System.out.println(":::Inside the WithDraw method :::"); } else { System.out.println(":::Inside the WithDraw method :::"); output = 0; } } public static void main(String[] args) { int amount, balance; // local variables BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); try { System.out.println("\t\t BANK ::::::::"); System.out.println("Enter the Amount value: "); amount = Integer.parseInt(in.readLine()); // Input value from keyboard for amount value System.out.println("Enter the Balance value: "); balance = Integer.parseInt(in.readLine()); // Input value from keyboard for balance value deposit(amount, balance); // deposit method called for computation System.out.println(":::Inside the Deposit method :::"); System.out.println("New Balance:::" + output); withdraw(amount, balance); // withdraw method called for compu System.out.println("New Balance:::" + output); } catch (Exception e) { System.out.println("Error:::" + e); } }
}
Ads