Java Main Program

  • Uploaded by: matju
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Java Main Program as PDF for free.

More details

  • Words: 243
  • Pages: 3
import javax.swing.*; import java.util.*; public class main { public static void main(String [] args) { LinkList woodList = new LinkList(); Stack MerantiStack = new Stack(); Stack ChengalStack = new Stack(); Stack tempStack = new Stack(); Stack currStack = new Stack(); JOptionPane j = new JOptionPane(); for(int i = 0;i<3;i++) { char woodtype = j.showInputDialog(null,"Enter Wood type Either C for Chengal and M for Meranti").charAt(0); float width = Float.parseFloat(j.showInputDialog(null,"Enter Width:")); float length = Float.parseFloat(j.showInputDialog(null,"Enter Length:")); float height = Float.parseFloat(j.showInputDialog(null,"Enter height:")); wood wd = new wood(woodtype,width,length,height); woodList.insertAtBack(wd); } wood w ; Object data = woodList.getFirst(); while(data!=null) { w = (wood)data; if (w.getWoodType() == 'M' || w.getWoodType() == 'm') { MerantiStack.push(data); } else if (w.getWoodType() == 'C' || w.getWoodType() == 'c') { ChengalStack.push(data); } data = woodList.getNext(); } int bigMeranti = smallMeranti bigChengal = smallChengal

0, = 0, 0, = 0,

tMeranti = 0, tChengal = 0, tBig = 0, tSmall = 0, allTotal = 0; while(!MerantiStack.isEmpty()) { data = MerantiStack.pop(); w = (wood)data; if (w.getWidth() >= 6.0 && w.getHeight() >=8.0) { bigMeranti++; } else { smallMeranti++; } tempStack.push(data); } while(!ChengalStack.isEmpty()) { data = ChengalStack.pop(); w = (wood)data; if (w.getWidth() >= 6.0 && w.getHeight() >=8.0) { bigChengal++; } else { smallChengal++; } } tBig = bigMeranti+bigChengal; tSmall = smallMeranti + smallChengal; tMeranti = bigMeranti + smallMeranti; tChengal = bigChengal + smallChengal; allTotal = tMeranti + tChengal; System.out.println("TYPE TOTAL");

BIG SIZE

SMALL SIZE

System.out.println("Meranti "+bigMeranti+" "+smallMeranti+" "+tMeranti); System.out.println("Chengal "+bigChengal+" "+smallChengal+" "+tChengal);

System.out.println("TOTAL "+tSmall+" "+allTotal);

}

}

"+tBig+"

Related Documents

Java Main Program
May 2020 7
Java Program
May 2020 17
Main Street Recovery Program
December 2019 19
Contoh Program Java
June 2020 8

More Documents from "Eddy Purwoko"