I HAVE A PROGRAM HERE THAT COMPUTES FOR I/O UTILIZATION. THERE'S ONLY ONE PROBLEM, I CANT SEEM TO FIND THE RIGHT PLACE TO PUT THESE CODE:
CPU=(mss/(ms+mss+msss))*100;
JOptionPane.showMessageDialog(null, "CPU Utlization:"+CPU+"%");
AS YOU CAN SEE I PLACED THE CODE ON THE LAST PART BUT WHEN I COMPILE THERE'S AN ERROR SAYING
"variable ms might not have been initialized"
BUT I ALREADY DID INITIALIZE VARIABLE ms.
PLEASE LET ME KNOW WHERE TO PUT THE CODE SO THAT THE PROGRAM CAN FUNCTION RIGHT. THANKS
import javax. swing.*;
public class CaseStudy{
public static void main(String[]args){
double ms, mss, msss, mssss, CPU; int input,charc,unit,unit1,unit2,unit3,unit4,card,outp ut,lines,inst;
double sec=.010;
{
//INPUT PHASE
input=Integer.parseInt(JOptionPane.showInputDialog ("Choose Input Device: \n (1)Keyboard \n (2)Cardreader"));
{
if (input==1){
charc=Integer.parseInt(JOptionPane.showInputDialog ("How Many Characters?"));
unit=Integer.parseInt(JOptionPane.showInputDialog( "Number Of Characters:"+charc+"\n In What Unit Of Time?\n(1)Microsecond \n(2)Millisecond\n(3)Second \n(4)Minute"));
if (unit==1)
mssss=(sec/charc);
else if (unit==2)
mssss=(1/charc);
else if (unit==3)
mssss=(1000/charc);
else
mssss=(60000/charc);
JOptionPane.showMessageDialog(null, "Input Phase:"+mssss+"ms");}
else{
card=Integer.parseInt(JOptionPane.showInputDialog( "How Many Cards?"));
unit2=Integer.parseInt(JOptionPane.showInputDialog ("Number Of Characters:"+card+"\n In What Unit Of Time?\n(1)Microsecond \n(2)Millisecond\n(3)Second \n(4)Minute"));
if (unit2==1)
ms=(sec/card);
else if (unit2==2)
ms=(1/card);
else if (unit2==3)
ms=(1000/card);
else
ms=(60000/card);
JOptionPane.showMessageDialog(null, "Input Phase:"+ms+"ms");}}
//OUTPUT PHASE
output=Integer.parseInt(JOptionPane.showInputDialo g("Choose Printer: (1)Laser (2)DotMatrix"));
{if (input==1){
lines=Integer.parseInt(JOptionPane.showInputDialog ("How Many Lines?"));
unit3=Integer.parseInt(JOptionPane.showInputDialog ("Number Of Lines:"+lines+"\n In What Unit Of Time?\n(1)Microsecond \n(2)Millisecond\n(3)Second \n(4)Minute"));
if (unit3==1)
msss=(sec/lines);
else if (unit3==2)
msss=(1/lines);
else if (unit3==3)
msss=(1000/lines);
else
msss=(60000/lines);
JOptionPane.showMessageDialog(null, "Output Phase:"+msss+"ms");}
else{
lines=Integer.parseInt(JOptionPane.showInputDialog ("How Many Lines?"));
unit3=Integer.parseInt(JOptionPane.showInputDialog ("Number Of Lines:"+lines+"\n In What Unit Of Time?\n(1)Microsecond \n(2)Millisecond\n(3)Second \n(4)Minute"));
if (unit3==1)
msss=(sec/lines);
else if (unit3==2)
msss=(1/lines);
else if (unit3==3)
msss=(1000/lines);
else
msss=(60000/lines);
JOptionPane.showMessageDialog(null, "Output Phase:"+msss+"ms");}}
//PROCESS PHASE
inst=Integer.parseInt(JOptionPane.showInputDialog( "How Many Instructions?"));
unit4=Integer.parseInt(JOptionPane.showInputDialog ("Instructions:"+inst+"\n In What Unit Of Time?\n(1)Microsecond \n(2)Millisecond\n(3)Second \n(4)Minute"));
{if (unit4==1)
mss=(inst/1000);
else if (unit4==2)
mss=(inst/1);
else if (unit4==3)
mss=(inst/sec);
else
mss=(inst/60000);
JOptionPane.showMessageDialog(null, "Process Phase:"+mss+"ms");
//CPU Utilization
CPU=(mss/(ms+mss+msss))*100;
JOptionPane.showMessageDialog(null, "CPU Utlization:"+CPU+"%");}
}}}}