Question

1. Write a program that calculates sales price of each article. The program will get the...

1. Write a program that calculates sales price of each article. The program will get the unit price of each article through the keyboard, and then calculate actual sales price. Actual sales price of each article is calculated as follows: • Sales Price = (2 x unit price) + (unit price x sales tax) Sales tax for each item is fixed to 5%. Your program should keep asking user to input unit price. If the user does not have any more articles to calculate sales price, then allow user to input -1 to stop calculating. Once a user input -1, your program should be terminated. The numbers used in the program represent dollar amounts. Therefore, your program allows only two decimal places. Your output should be similar to the following:

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

code in c:

#include <stdio.h>

struct MyStruct //struct to read float variable
{
float p;
} newMyStruct;

int main(void) {
   // your code goes here
   float up,sp,st; // declaring variables
   st = 0.05; //sales tax
   int looper =0;
   while (looper<1 ) //loop to check -1 input from user
   {
   printf("Enter unit price of article:\n");
   scanf("%f",&(newMyStruct.p));
   up =newMyStruct.p;
   if (up==-1.000000)
   {
   looper++;
   printf("Program exits....");
  
   }
else
{
   sp =(2*up +up*st);
   printf("sales price is %.2f\n",sp); //calculations
     
   }
   }
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
1. Write a program that calculates sales price of each article. The program will get the...
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
  • Write a C++ program that calculates the discount of the original price of an item and...

    Write a C++ program that calculates the discount of the original price of an item and displays the new price, and the total amount of savings. This program should have a separate header (discount.h), implementation (discount.cpp) and application files (main.cpp). The program must also have user input: the user must be prompted to enter data (the original price, and the percent off as a percentage). There must also be a validation, for example: Output: “Enter the original price of the...

  • Answer using C++ Write a program that will calculate the final sales price of a motorcycle;...

    Answer using C++ Write a program that will calculate the final sales price of a motorcycle; this includes additional optional packages along with sales tax. You may assume that the base? price of the motorcycle is $30,000. First you must ask the user to choose which optional packages they want. The user is only permitted to choose one package. Your program should display a menu of the available packages. The user should enter the package by entering the letter associated...

  • Write a java programm that calculates the total of a retail sale should ask the user...

    Write a java programm that calculates the total of a retail sale should ask the user for the following: The retail price of the item being purchased The sales tax rate Once these items have been entered, the program should calculate and display the following: The sales tax for the purchase The total of the sale I tried doing it here. but it is not giving me the right answer. kindly help correct the errors. import java.util.Scanner; public class SalesTax...

  • Python Simple Programming Write a program in Python that calculates the tip and total for a...

    Python Simple Programming Write a program in Python that calculates the tip and total for a meal at a restaurant. When your program is run it should ... Calculate the tip and total for a meal for a restaurant Print the name of the application "Tip Calculator" Get input from the user for cost of meal and tip percent Print the tip and total amounts. The formula for calculating the tip amount is: tip = cost of meal * (tip...

  • Part A) Write a C++ program that calculates the area under a curve. Here is the...

    Part A) Write a C++ program that calculates the area under a curve. Here is the equation: f(x) = x^2 +1.5x +4 You must prompt the user for the beginning and the ending x values. You are to assume, but not check, that the user will put in whole positive numbers. The units are inches. The program input/output should look something like this: This program calculates the area under a curve between two points on the x axis. The equation...

  • USING PYTHON PLEASE Write a program that calculates the factorial value of a number entered by...

    USING PYTHON PLEASE Write a program that calculates the factorial value of a number entered by the user. Remember that x! =x* (x-1)* (x-2)*... *3+ 2* 1. Your program should check the value input by the user to ensure it is valid (i.e., that it is a number > =1). To do this, consider looking at the is digit() function available in Python. If the user enters an incorrect input, your program should continue to ask them to enter a...

  • Java I: Create a Java program that will accept the price of an item and the...

    Java I: Create a Java program that will accept the price of an item and the quantity being purchased of that item. After accepting the input, calculate the amount of the purchase (based on the price and quantity), calculate the sales tax on the purchase, then output the product price, quantity, subtotal, sales tax, and the total sale based on the output format shown below. Structure your file name and class name on the following pattern: The first three letters...

  • Question 4-6 Please. Python 3.6. def main(). entered by a user. Write a program that finds...

    Question 4-6 Please. Python 3.6. def main(). entered by a user. Write a program that finds the sum and average of a series of numbers he program should first prompt the user to enter total numbers of numbers are to be summed and averaged. It should then as for input for each of the numbers, add them, and print the total of the numbers and their average 2. Write a progra m that finds the area of a circle. The...

  • #1 Write a java program which calculates the area of either a Triangle or a Rectangle....

    #1 Write a java program which calculates the area of either a Triangle or a Rectangle. Use Scanner to take an input field to tell you if the area to be calculated is for a Triangle or is for a Rectangle. Depending on that input - the program must call either the Triangle method or the Rectangle method. Each of those methods must receive 2 input fields from the user - one for base and one for height in order...

  • Write a shell script that given a radius, calculates the area of a circle. (Hint –...

    Write a shell script that given a radius, calculates the area of a circle. (Hint – don’t write this from scratch. Find another script that reads user input and performs a calculation, then modify it to meet your needs.) Save the script in your home directory with the name circle.sh The formula for calculating the area is: Area=Π*Radius2 You can use 3.14 for Π, and either do Radius*Radius or Radius^2 to get the square of the radius. Use the scale...

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
ADVERTISEMENT