I'm a newbie at java and I need help in coming up with the correct answer for this JOption java program. I enter in 2k, 30fps, 4min, 0seconds, and I should get 10.6842041GB (16.02630615GB total space needed). Please let me know if you have any advice on how I could fix this?
Thanks!
-A
import javax.swing.*;
import java.lang.*;
import java.io.*;
public class storageSP {
public static void main(String[] args) {
//declare variables
int res;
String kfilm;
int cb;
String sfps;
int fps;
int newNo;
String sminutes;
String sseconds;
int minutes;
int seconds;
int minsec;
int Bit;
int Byte;
int kbyte;
int mbyte;
int gbyte;
int tbyte;
//int pbyte; if needed in the future
int istorage;
float storage;
double perc;
double storagePt5;
double dultStorage;
int ultStorage;
//#get k of film
kfilm = JOptionPane.showInputDialog("Please enter film type 1k,2k, 4k, or 8k? ");
if (kfilm.equals("1k")){
res = 1024*778;//796672
}
else if (kfilm.equals("2k")){
res = 2048*1556;//3186688
}
else if (kfilm.equals("4k")){
res = 4096*3112;//12746752
}
else if (kfilm.equals("8k")){
res = 8192*6224;//50987008
}
else {
res = 0;
}
cb = res*4;//#resolution of frame with RGBA channels
//get fps
sfps = JOptionPane.showInputDialog("How many frames/second? 30 (COMMON - mono), 60 (stereo), or 24 (film) ");
fps = Integer.parseInt(sfps.trim());
//newNo for Bits later
newNo = cb*fps;
//How long?
sminutes = JOptionPane.showInputDialog("How many minutes? ");
sseconds = JOptionPane.showInputDialog("How many seconds? ");
minutes = Integer.parseInt(sminutes.trim());
seconds = Integer.parseInt(sseconds.trim());
if (minutes>0){
minsec = minutes*60;
minsec = minsec+seconds;
}
else {
minsec = seconds;
}
//# Measurement in Bits, Bytes...etc
Bit = newNo*minsec;
Byte = Bit/8;
kbyte = Byte/1024;
mbyte = kbyte/1024;
gbyte = mbyte/1024;
tbyte = gbyte/1024;
//# figure the bits, bytes, kbytes, mbytes, gbytes, tbytes, or pbytes needed
if (Bit < 1024){
JOptionPane.showMessageDialog(null, Bit + " Bits");
istorage = Bit;
}
else if (Byte < 1024){
JOptionPane.showMessageDialog(null, Byte + " Bytes");
istorage = Byte;
}
else if (kbyte < 1024){
JOptionPane.showMessageDialog(null, kbyte + " kB");
istorage = kbyte;
}
else if (mbyte < 1024){
JOptionPane.showMessageDialog(null, mbyte + " MB");
istorage = mbyte;
}
else if (gbyte < 1024){
JOptionPane.showMessageDialog(null, gbyte + " GB");
istorage = gbyte;
}
else if (tbyte < 1024){
JOptionPane.showMessageDialog(null, tbyte + " Terabytes");
istorage = tbyte;
}
else{
return;
}
storage = (float)istorage;
//#need to ensure proper storage space
JOptionPane.showMessageDialog(null, "PLEASE NOTE to add more storage space \nso the project runs more smoothly!!");
//storagePt5=storage*.5
perc = 0.5;
storagePt5 = Math.floor(storage*perc);
dultStorage = storage*storagePt5;
ultStorage = (int)dultStorage;
JOptionPane.showMessageDialog(null, "So try " + ultStorage);
}
}