Answer to Question #230424 in Java | JSP | JSF for Cypher

Question #230424
COVID-19 has triggered panic buying from Ghanaians with the expectation
that there will be declaration of lockdown after the closure of school across the
country. Retailer are increasing the prices of their goods on the shelf based on
the time it stays on the shelf. The management of “Brutus Stores” have decided on this price policy. The price of any item which is expected to sell within a
week should be increased by 20%. However, if an item stays on the shelf after a week but less than or equal to two weeks the price should be increase by 15%. The price of any other item that stays on the shelf for more than two weeks should be increase by 2%. As a programmer you have been consulted to
develop a program that will:

a. Request for item name, current price in GHc, expected duration on shelf
b. Compute the retail price of the item
c. Display the results
d. Explain your results
1
Expert's answer
2021-08-29T00:57:55-0400
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) {
		String name;
        double cprice;
        int duration;
        Scanner in=new Scanner(System.in);
        System.out.println("Enter name: ");
        name=in.next();
        System.out.println("Enter current price: ");
        cprice=in.nextDouble();
        System.out.println("Enter duration: ");
        duration=in.nextInt();
        
        double retail_price=0.0;
        if(duration<=7)
            retail_price=1.20*cprice;
        else if(duration>7 && duration<=14)
            retail_price=1.15*cprice;
        else if(duration>14)
            retail_price=1.02*cprice;
        
        System.out.println("Name: "+name);  
        System.out.println("Current price: "+ cprice); 
        System.out.println("Duration: "+ duration); 
        System.out.println("Retail price: "+ retail_price); 
        
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS