Discount – 20%

The program must accept the price of an item as the input. The program must print the price of the item after 20 percent discount with the precision up to two decimal places as the output.

Example Input/Output:
Input:
29

Output:
23.20

Python

price = int(input())
print(format(price*0.8, '.2f'))

Java

import java.util.*;
public class Hello {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int price = sc.nextInt();
        System.out.printf("%.2f", price * 0.8);
    }
}

C

#include <stdlib.h>
#include  <stdio.h>
int main()
{
    int price;
    scanf("%d", &price);
    printf("%.2f", price*0.8);
    return 0;
}

C++

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
    int price;
    cin >> price;
    cout << fixed << setprecision(2) << price*0.8;
    return 0;
}
Previous Article

String - Print Twice

Next Article

Print Last Four Digits

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *