Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a flow chart for this java program import java.util.Scanner; import java.text.DecimalFormat; public class tnb { public static void main(String[] args) { Scanner sc =

Write a flow chart for this java program

import java.util.Scanner; import java.text.DecimalFormat; public class tnb { public static void main(String[] args) { Scanner sc = new Scanner(System.in); DecimalFormat df=new DecimalFormat ("0.00"); double total=0; double KWTBB; System.out.println("CURRENT METER READING: "); int CMR=sc.nextInt(); System.out.println("PAST METER READING: "); int PMR=sc.nextInt(); double kWh=CMR-PMR; System.out.println(); System.out.println("BLOCK PRORATA: "); kwh(CMR,PMR); double rebatICPT=kWh/50; if (kWh<=200) { total=kWh*0.218; } else if (kWh>200 && kWh<=300) { total= (200*0.218)+((kWh-200)*0.334); } else if (kWh>300 && kWh<=600) { total= (200*0.218)+(100*0.334)+ ((kWh-300)*0.516); } KWTBB=((total*2)/125); System.out.println(); System.out.println("Total: RM"+(df.format(total))); System.out.println(); System.out.println("REBAT ICPT (RM0.02/kWh):"); System.out.println(df.format(total)+ " - " +rebatICPT+ " = RM " +(df.format((total-rebatICPT)))); System.out.println(); System.out.println("KWTBB (1.6%): "+ (df.format(KWTBB))); System.out.println(); System.out.println("Final Total: RM "+(df.format((total-rebatICPT)+KWTBB))); } public static void kwh (int a,int b) { System.out.print(a-b); System.out.println(); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions