improved tui integration

This commit is contained in:
array-in-a-matrix 2021-11-05 18:20:37 -04:00
parent d05cb38140
commit 9a04c7ff2b
2 changed files with 53 additions and 31 deletions

View file

@ -9,27 +9,14 @@ int main(int num_arg, char **args)
if (num_arg <= 1)
{
system("clear");
printf("\n ~~ Quadratic Calculator ~~\n");
printf(" ̲ ̲ ̲ ̲ ̲ ̲\n");
printf(" ̲-̲b̲±̲√̲b̲̲²̲̲-̲4̲a̲c̲\n");
printf(" 2a\n\n");
printf("Please enter the value for \"a\":\n");
scanf("%lf", &num_A);
printf("Please enter the value for \"b\":\n");
scanf("%lf", &num_B);
printf("Please enter the value for \"c\":\n");
scanf("%lf", &num_C);
printf("\n");
system("/bin/sh ./tui.sh");
}
else
{
num_A = atof(args[1]);
num_B = atof(args[2]);
num_C = atof(args[3]);
};
double radical = pow(num_B, 2) + (-4 * num_A * num_C);
if (radical < 0.0)
@ -50,5 +37,6 @@ int main(int num_arg, char **args)
printf("%f %f\n", zero_1_ptr, zero_2_ptr);
};
};
return 0;
};

34
tui.sh Executable file
View file

@ -0,0 +1,34 @@
#!/bin/sh
ARG_A=$(whiptail --inputbox "Please enter the value for \"a\":" 10 50 --title "Quadratic Calculator" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
echo "a =" $ARG_A
else
echo "User canceled input."
exit
fi
ARG_B=$(whiptail --inputbox "Please enter the value for \"b\":" 10 50 --title "Quadratic Calculator" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
echo "b =" $ARG_B
else
echo "User canceled input."
exit
fi
ARG_C=$(whiptail --inputbox "Please enter the value for \"c\":" 10 50 --title "Quadratic Calculator" 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
echo "c =" $ARG_C
else
echo "User canceled input."
exit
fi
echo
./quadratic $ARG_A $ARG_B $ARG_C