Answer to Question #235919 in Java | JSP | JSF for Princess

Question #235919
If the user makes an incorrect product category selection, prompt the user to re-enter a valid product category.

Provide the user with the option to select between the following product warranty

options:

1-Applies a six-month product warranty.

Any other key applies a two-year warranty.

Once the entire submission has been completed, the user must be informed that the

product details have been successfully saved.
1
Expert's answer
2021-09-11T23:39:44-0400
import java.util.Scanner;


public class Main
{
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		String c;
		int warranty=0;
		while( true ){
    		System.out.println("Select between the following product warranty: ");
    		System.out.println("1-Applies a six-month product warranty.\nAny other key applies a two-year warranty.");
    	    c=in.next();
    	    
    	    if (c=="1"){
    	        warranty=6;
    	        System.out.println("Product details have been successfully saved");
    	        break;
    	    }
    	    else{
    	        warranty=24; //2years
    	        System.out.println("Product details have been successfully saved");
    	        break;
    	    }
    	         
		}
		
	    
	}
}

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