Skip to main content

TCS Java Coding Question Day 2 Slot 1 : Property Painting

 

// TCS Java Coding Question Day 2 Slot 1 : Property Painting

 

import java.util.Scanner;

class Prop_paint {

    public static void main(String[] args) {

       int ni, ne, i = 0;

       float intP = 18, extP = 12, cost = 0, temp;

       Scanner sc = new Scanner(System.in);

       System.out.printf("Number of Interior Walls : ");

       ni = sc.nextInt();

       System.out.printf("\nNumber of Exterior Walls : ");

       ne = sc.nextInt();

       if(ni < 0 || ne < 0) {

           System.out.print("INVALID INPUT");

       } else if(ni == 0 && ne == 0) {

           System.out.print("\nTotal estimated Cost : 0.0");

       } else {

           for(i = 0; i < ni; i++) {

               temp = sc.nextFloat();

               cost += intP * temp;

           }

           for(i = 0; i < ne; i++) {

               temp = sc.nextFloat();

               cost += extP * temp;

           }

           System.out.printf("\nTotal estimated Cost : %.1f", cost);

           System.out.printf("\n");

 

       }

    }

}

 

Comments