Computer Science, asked by purnasripodila, 2 months ago

Checking budget of mobile
Write a java program to find the mobile chosen is within the budget or not. To find the budget mobiles is based on the below-mentioned criteria,

a)If the cost of the mobile chosen is less than or equal to 13000 then display it as "Mobile chosen is within the budget"

b)If the cost of the mobile chosen is greater than 13000 then display it as "Mobile chosen is beyond the budget"



Sample Input 1:

Enter the cost of the mobile

12000

Sample Output 1:

Mobile chosen is within the budget



Sample Input 2:

Enter the cost of the mobile

22000

Sample Output 2:

Mobile chosen is beyond the budget

Answers

Answered by dreamrob
4

Program:

import java.util.*;

public class MyClass

{

   public static void main(String args[])

   {

       Scanner Sc = new Scanner(System.in);

       int cost;

       System.out.print("Enter the cost of the mobile : ");

       cost = Sc.nextInt();

       if(cost <= 13000)

       {

           System.out.print("Mobile chosen is within the budget");

       }

       else

       {

           System.out.print("Mobile chosen is beyond the budget");

       }

   }

}

Output 1:

Enter the cost of the mobile : 12000

Mobile chosen is within the budget

Output 2:

Enter the cost of the mobile : 22000

Mobile chosen is beyond the budget

Answered by bhargavibhanu2311
3

Answer:

import java.util.Scanner;public class Main{public static void main(String[] args){Scanner sc=new Scanner(System.in);System.out.println("Enter the cost of the mobile ");float cost=sc.nextFloat();if(cost <= 13000){System.out.println("Mobile chosen is within the budget");}else if(cost >= 13000){System.out.println("Mobile chosen is beyond the budget");}else{System.out.println(" ");}}}

Similar questions