Question

Trying to write this in java code but I'm running into a lot of errors.

package receipt;

public class Receipt {

   {
     
   int quantity=2, tax=7,i;
   String item="0010", description="Paper";
   double amt=1.99, amount=4.26, total=12.78,
   ("\t\t\t\t", "Receipt");
   ("Item#\t", "Description\t", "Amt\t", "Quantity\t", "Tax\t", "Amount\t");
   for(i=1;i<=3;i++)
   {
   cout<<item<<"\t"<<description<<"\t\t"<<amt<<"\t"<<quantity<<"\t\t"<<tax<<"%\t"<<amount<<endl;
   }
   cout<<"\n\t\t\t\t\t\tTotal\t"<<total<<endl;
   return;
   }}

The end result would look like this.

Receipt Item# Description Amt Quantity Tax Amount 0010 Paper 0010 Paper 0010 Paper 1.99 1.99 1.99 7% 4.26 790 4.26 7% 4.26 To

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The corrected program is

package receipt;
public class Receipt {

    public static void main(String[] args)
    {
    int quantity=2, tax=7,i;
    String item="0010", description="Paper";
    double amt=1.99, amount=4.26, total=12.78;
    System.out.println("\t\t\t\tReceipt");
    System.out.println("Item#\tDescription\tAmt\tQuantity\tTax\tAmount\t");
    for(i=1;i<=3;i++)
    {
    System.out.println(item+"\t"+description+"\t\t"+amt+"\t"+quantity+"\t\t"+tax+"%\t"+amount);
    }
    System.out.println("\n\t\t\t\t\t\tTotal: \t"+total);
}
    }
   

Output

Add a comment
Know the answer?
Add Answer to:
Trying to write this in java code but I'm running into a lot of errors. package...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Use this code to create multiple functions. #include<iostream> #include<iomanip> #include<fstream> using namespace std; int main() {...

    Use this code to create multiple functions. #include<iostream> #include<iomanip> #include<fstream> using namespace std; int main() { cout << fixed << showpoint << setprecision(2); ofstream outFile; outFile.open("Feras's.txt"); outFile << "..Skinny Feras's Restaurant ..\n\n" << endl; int choise=10, quantity; float paid, SubTotal=0, Tax = .10, Total, RM, more; while(choise!=0) { system("cls"); cout << "\t**Welcome To Skinny Alsaif Restaurant Lol**" << endl; cout << "\nWhat would you like to have?" << endl; cout << "1. Burger." << endl; cout << "2. Pizza." <<...

  • Use java and continue stage 2 and 3 stage 1 code public abstract class BabyItem { protected String name;...

    Use java and continue stage 2 and 3 stage 1 code public abstract class BabyItem { protected String name; public BabyItem() { name=""; } public BabyItem(String name) { this.name = name; } public String getName() { return name; } public void setName(String name) { } public abstract double getCost(); } ======================================================================================== public class BabyFood extends BabyItem { private int numberOfJars; private double pricePerDozen; public BabyFood() { super(); numberOfJars = 0; pricePerDozen = 0; } public BabyFood(int numberOfJars, double pricePerDozen) {...

  • What's wrong with my code? : I'm trying to use recursive functions to display and count...

    What's wrong with my code? : I'm trying to use recursive functions to display and count all the even numbers of an array. However, I can't seem get the program output the number of even integers . Here's the output I want: Here are the 5 even numbers: // Luckily, however, my code does output all the even numbers. But, I also want the program to tell me how may even integers there are. 2 8 14 18 22 MY...

  • Need help with a C++ problem I have

    For my assignment I have to write a program that creates a restaurant billing system. I think that I got it correct but it says that it is incorrect, so I was wondering if someone would be able to look over my code. It says that I need tax of $0.20, and the amount due to be $4.10, which is what I have in my output.https://imgur.com/a/jgglmvWMy issue is that I have the correct outcome when I run my program but...

  • i need help making this program the skeleton of the code is below: //Include the following #include <iostream> #...

    i need help making this program the skeleton of the code is below: //Include the following #include <iostream> #include <string> #include <fstream> //you must include this library if you wish to do file i/o using namespace std; /********************************************************* //Following is the declaration of a order record **********************************************************/ class order_record { public: string cell_number; string item_number; double quantity; double price; int processing_plant; double tax_rate; double order_tax; double net_cost; double total_cost; }; //Prototypes for your functions: input, output, and process will go...

  • Can someone please properly answer all the questions listed below? I know it's a lot of...

    Can someone please properly answer all the questions listed below? I know it's a lot of questions, but it would really mean a lot if someone could help. I'd greatly appreciate it. P.S (I know as per chegg guidlines you can only answer a set amount of questions. But there’s been multiple times where I post like 10-20 question or so and people completely answer them. And others who only answer 1 single question out of everything else. I posted...

  • Ch 1 1. Given the following dat Dec 31 Year 2 Dec 31 Year 1 Total...

    Ch 1 1. Given the following dat Dec 31 Year 2 Dec 31 Year 1 Total liabilities S128,250 $120,000 Total stockholders oquity 95.000 80.000 compute the ratio of liabilities to stockholders' equity for each year Round to two decimal places 1.50 and 107, 11.35 and 1.50 respectively respectively 1.07 and 1.19. 1.1.19 and 1.35 respectively respectively The liabilities and stockholder's equity of a company are $132,000 and $244.000, respectively. Assets should equal SS188.00 $132.00 p $376,00 12.000 A financial statement...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT