45.3k views
0 votes
Using a word processor of your choice, write the pseudocode for an application that allows a user to enter the price of an item and computes 10 percent sales tax on the item and prints out for the user the original price and the tax and the total. Remember to declare the class and the main method.

2 Answers

6 votes

Answer:

#Python

class PriceTax:

def __init__(self): #Main method

self.itemPrice = int(input("Price of your item: "))

self.tax = 0.1

self.total = round(self.tax*self.itemPrice,2)

print("\\Original price: ", self.itemPrice)

print("Tax: %d%%" % (self.tax*100))

print("Total: ", self.total)

price = PriceTax()

Step-by-step explanation:

We define a class called PriceTax with a main method __init__, we asked for the user input and store the int value in an attribute called itemPrice, we define the tax attribute and we calculate the total by multiplying the predefined tax and the item price entered by the user. Finally, we print the original price, the tax, and the total. Note that for this to work we instantiate the class 'PriceTax' first under the variable price.

Using a word processor of your choice, write the pseudocode for an application that-example-1
User Matt Morgan
by
4.9k points
5 votes

Answer:

// here is pseudo-code and implementation in java.

import java.util.*;

// class definition

class Solution

{

// main method of the class

public static void main (String[] args) throws java.lang.Exception

{

try{

// scanner object to read innput

Scanner s=new Scanner(System.in);

// variables

double item_cost;

System.out.print("Please enter cost of item:");

//read the cost of item

item_cost=s.nextDouble();

// calculate 10% tax on the item

double tax=item_cost*0.1;

// print original cost

System.out.println("original cost of item is: "+item_cost);

// print tax on the item

System.out.println("tax on the item is: "+tax);

// print total cost of item

System.out.println("total cost of item is:"+(item_cost+tax));

}catch(Exception ex){

return;}

}

}

Step-by-step explanation:

Read the original cost of item from user and assign it to variable "item_cost". Calculate 10% tax on the cost of item and assign it to variable "tax".Print the original cost and tax on item.Then add the cost and tax, this will be the total cost of item and print it.

Output:

Please enter cost of item:125

original cost of item is: 125.0

tax on the item is: 12.5

total cost of item is:137.5

User Rorist
by
6.3k points