Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions Please give me the code for the below problem

Have Programming Question? Ask it here!
 
 
 


vidya
Please give me the code for the below problem
1 Answer(s)      4 years and 5 months ago
Posted in : Java Interview Questions



Advertisement
View Answers

November 16, 2009 at 3:31 PM


Hi Friend,

Try the following code:

import java.util.*;
class Tax{
int qty = 0;
String prodName = null;
float price = 0.0f;
boolean imported = false;
boolean exempted = false;
float tax = 0.0f;

void calculateSalesTax() {
float totalTax = 0.0f;
if(imported)
totalTax = 0.05f;
if(!exempted)
totalTax = .1f;
if((imported)&&(!exempted))
totalTax = .15f;
tax = totalTax * price;
}

public String toString() {
float p=price+tax;
return qty+" "+prodName+" at "+p;
}
}
public class SalesTax{
public static void main(String [] args) throws Exception{
SalesTax st = new SalesTax();
Scanner input = new Scanner(System.in);
ArrayList<Tax> list = new ArrayList<Tax>();
int no = 1;
while(true){
Tax tax = new Tax();
System.out.println("Add Products: "+no);
System.out.print("Quantity: ");
int qty = input.nextInt();
tax.qty = qty;
System.out.print("Product prodName: ");
String prod = input.next();
tax.prodName = prod;
System.out.print("Price: ");
float p = input.nextFloat();
tax.price = p;
System.out.print("Is it Imported[y/n]: ");
String imp =input.next();
if(imp.toLowerCase().equals("y"))
tax.imported = true;
System.out.print("Is it Exempted[y/n]: ");
String exe = input.next();
if(exe.toLowerCase().equals("y"))
tax.exempted = true;
tax.calculateSalesTax();
list.add(tax);
no++;
System.out.print("Add More Products [y/n]: ");
String add = input.next();
if(add.toLowerCase().equals("n"))
break;
}
float tp = 0.0f;
float tt = 0.0f;
for(int i=0; i<list.size(); i++) {
Tax tax = list.get(i);
tp += tax.price;
tt += tax.tax;
System.out.println(tax);
}

System.out.println("Sales Taxes:"+tt);
System.out.println("Total: "+(tp+tt));

}

}

Thanks


Related Tutorials/Questions & Answers:
Please give me the code for the below problem - Java Interview Questions
Please give me the code for the below problem  PROBLEM : SALES TAXES Basic sales tax is applicable at a rate of 10% on all goods, except books... Vidya  Hi Friend, Try the following code: import java.util.
Give me the source code for this problem
Give me the source code for this problem  Ram likes skiing a lot. That's not very surprising, since skiing is really great. The problem with skiing... is connected to another if it's at left, at right, above or below it. In the sample
Advertisements
Please tell me the code to generate the below structure
Please tell me the code to generate the below structure  1 2 3 4 5 6 7 8 9 1 2 3 4 6 7 8 9 1 2 3 7 8 9 1 2 8 9 1 9 1 2 8 9 1 2 3 7 8 9 1 2 3 4 6 7 8 9 1 2 3
please help me to give code - Java Beginners
please help me to give code  Write a function, sliding(word, num)that behaves as follows. It should print out each slice of the original word having length num, aligned vertically as shown below. A call to sliding(examples, 4
please help me to give code - Java Beginners
please help me to give code  Write a function with a signature cheerlead(word) that prints a typical cheer as follows. The word robot: Gimme an R Gimme an O Gimme a B Gimme an O Gimme a T What did you give me? ROBOT
please help me to give code - Java Beginners
please help me to give code  Write a program that prints an n-level stair case made of text. The user should choose the text character and the number of stairs in the stair case * ** *** ****   Hi friend
please help me to give code - Java Beginners
please help me to give code  Write a program that uses loops to generate an n x n times table. The program should get n from the user. As a model here is a 4 x4 version: | 1 2 3 4
please help me to give code - Java Beginners
please help me to give code  Write a program that reads a file named famous.txt and prints out the line with the longest length. In the case of a tie, you may print out only one of them. For example in the file: Alan Turing
how to send email please give me details with code in jsp,servlet
how to send email please give me details with code in jsp,servlet  how to send email please give me details with code in jsp,servlet
Please give me the answer.
"int a=08 or 09" its giving compile time error why   "int a=08 or 09" its giving compile time error why ? can any one give me the answer of this please
Please give me coding for this..
Please give me coding for this..  Write an application that inputs one number consisting of five digits from the user.separates the number ibto its individual digits and prints the digits separated from one another by three
please help me to this problem..
please help me to this problem..  i wrote a program like keyboard... inside the JTextField) but i want to make this program to let me write where i clicked (i.e allows me to write any thing at the field where i clicked
please help me to overcome this problem
please help me to overcome this problem  how to make it easy to write java code. can u please give me suggestions
please give me an idea to develop a program for this question?
please give me an idea to develop a program for this question?  How to enter a text or number from keyboard without using InputStreamReader method in java
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 give me a java program for the following question
please give me a java program for the following question  Write...; In the previous code, we forget to add an icon to button. So we are sending the updated code. import java.awt.*; import javax.swing.*; import
verify the code and give me the code with out errors
verify the code and give me the code with out errors   import...(); } } when i run this program... it shows the given below errors.pls clear the errors and give me correct tutorial for my knowledge improving.pls anyone
please give me an example about shopping cart using spring and hibernate
please give me an example about shopping cart using spring and hibernate  who can give me an ex about shoppingcart using spring and hibernate intergration ? thanks alot
hi.. please give me a java coding for the following question
hi.. please give me a java coding for the following question  Body Mass Index(BMI) is a measure of health on weight. It can be calculated by taking... Interpretation Below 16 seriously
hi.. please give me a java coding for the following question
hi.. please give me a java coding for the following question  Write a program that displays the following table (note that 1 mile is 1.609 kilometers). Miles Kilometers
hi.. please give me a java coding for the following question
hi.. please give me a java coding for the following question  Write a program that prompts the user to enter the number of students and each studentā??s name and score, and finally displays the name of the students
hi.. please give me a java coding for the following question
hi.. please give me a java coding for the following question  Write a program that reads in investment amount, annual interest rate, and number of years, and displays the future investment value using the following formula
hi.. please give me a java coding for the following question
hi.. please give me a java coding for the following question  Suppose that the tuition for a university is RM10,000 this year and increases 5% every year. Write a program that computes the tuition in ten years and the total cost
hi.. please give me a java coding for the following question
hi.. please give me a java coding for the following question  Write a function called ChangeToNext that take in an uppercase character parameter ch. The function returns the next uppercase character if ch is between 'A' and 'Y
hi.. please give me a java coding for the following question
hi.. please give me a java coding for the following question  Write a class that contains the following two methods: /* converts from inches to centimeters */ Public static double inchToCentimeter(double in) /* converts from
problem in writing coding. Please help me.
problem in writing coding. Please help me.  Hi sir, my name is Logeswaran. I have problem in writing JSP coding for my university assigments... like? I'm really stuck on this. Please help me. By the way, I'm using Access
hello sir, please give me answer - Java Beginners
hello sir, please give me answer  Write a program in Java that calculates the sum of digits of an input number, prints... ways in java? so , sir please tell me full solution of this program   Here is your complete
Hi Every One , please give me some idia to opning audio File . please Help ..
Hi Every One , please give me some idia to opning audio File . please Help ..  hi Dear Friend , please give me a program to opening audio file... me .please Help
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 2 1 1 3 4 3 1 1 4 7 7 4 1
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
give me source code of webpage creation using html
give me source code of webpage creation using html  how to create a webpage using html
please convert for me this code to GUI - Swing AWT
please convert for me this code to GUI    THE CODES ARE BELOW...; } else screen.displayMessageLine( "\nInvalid account Nummber or PIN, Please...; screen.displayMessageLine("\n Your cash has been"+ "dispensed. please take your cash
please convert for me this code to GUI - Swing AWT
please convert for me this code to GUI  THE CODES ARE BELOW, CLASS ATMCaseStudy is the driver class that runs all the other classes. its very urgent... account Nummber or PIN, Please try again."); } private void
Please help me fix this code - MobileApplications
Please help me fix this code   Please help me in this area of code... in the background of the forms in this code i want to sum all expenses amount... expenses)", "Please fill all required field \n \n * This signify required field
i have problem with this query... please tell me the resolution if this .........
i have problem with this query... please tell me the resolution if this .........  select length(ename)||' charecters exist in '||initcap(ename)||'s name' as "names and length" from emp
i have problem with this query... please tell me the resolution if this .........
i have problem with this query... please tell me the resolution if this .........  select initcap(ename),job from emp where substr(job,4,length(job,4,3)))='age
Pleae help me to give logic and code for this program - Java Beginners
Pleae help me to give logic and code for this program  Write a function that given the string ?original? create a new string ?dramatic? that has two consecutive copies of each letter from the original string. For example
why and where we use setter and getter methods in java, please give me one example program.....
why and where we use setter and getter methods in java, please give me one example program.....  why and where we use setter and getter methods in java, please give me one example program
Please help me to modify my java code from php code
]; } } I tried like this (see below JSP code) ... but this is not giving me the exact result as the above PHP code is giving. So please help me to convert...Modify Java code from PHP Code  i want to covert this php code int
plz help me out with this problem...please write the program for me.thanxxxxx
plz help me out with this problem...please write the program for me.thanxxxxx  Write a program that will print out a hydro bill. The bill... will be entered by the user: - Account number (12 digit code) - Address - Kilowatts used
plz help me out with this problem...please write the program for me.thanxxxxx
plz help me out with this problem...please write the program for me.thanxxxxx  Write a program that will print out a hydro bill. The bill... will be entered by the user: - Account number (12 digit code) - Address - Kilowatts used
Please help me to modify my java code from php code
Please help me to modify my java code from php code  i want to covert...]); $array[] = $item[1]; } } I tried like this (see below JSP code) ... but this is not giving me the exact result as the above PHP code is giving. So please
please give me solution how to display next page after 20 records ? - JSP-Servlet
please give me solution how to display next page after 20 records ?  Java Servlet Paging control example  here i have attached one example code. function validate() { for(j=0;j<30;j
i want java code for this xml file...please show me..
i want java code for this xml file...please show me..   xbrli:shares xbrli:pure iso4217:INR
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?  1) Copy one file content to other? 2) Count the number of words in a file
Please help me to write a code for add contacts to groups in a website?
Please help me to write a code for add contacts to groups in a website?   Iam developing a site. In that site I need to write code for Groups... send a code for this? Please make it fast
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?  Q 1) In a class first day 25 students are joined. After two days that total students will increased to 60. We can develop a program by using ArrayList concept
plz give me answer
plz give me answer  Discuss & Give brief description about string class methods   Java string methods
plz give me answer
plz give me answer   description about string class methods   Java string methods
plz give me answer
plz give me answer   description about string class methods   Java string methods
 

 

 

DMCA.com