Post: Need help in java
04-27-2014, 06:22 PM #1
HaZeYMan
Do a barrel roll!
(adsbygoogle = window.adsbygoogle || []).push({}); I WANTED THIS TRANSLATED INTO JAVA FORM. PLEASE!! THANKS


#include <stdio.h>
#include <math.h>

void liqui(int ,int*,int*,int*,int*);

int main()
{
int num1, gallons, quarts, pints, cups;

printf("Enter the number of cups:");
scanf("%2d",&num1);

liquid(num1, &gallons, &quarts, &pints, &cups);

return 0;
}

void liquid(int x, int *gallons, int *quarts, int *pints, int *cups)
{
static int y;
y = x;

if (y >= 16)
{
*gallons = (y / 16);
printf("The number of gallons is %3d\n", *gallons);
}
if (y - (*gallons * 16) >= 4)
{
*quarts = ((y - (*gallons * 16)) / 4);
printf("The number of quarts is %3d\n", *quarts);
}
if ((y - (*gallons * 16) - (*quarts * 4)) >= 2)
{
*pints = ((y - (*gallons * 16) - (*quarts * 4)) / 2);
printf("The number of pints is %3d\n", *pints);
}
if ((y - (*gallons * 16) - (*quarts * 4) - (*pints *2)) < 2 || y == 0)
{
*cups = (y - (*gallons * 16) - (*quarts * 4) - (*pints *2));
printf("The number of cups is %3d\n", *cups);
}
return;
}
(adsbygoogle = window.adsbygoogle || []).push({});
04-29-2014, 06:13 PM #2
Pichu
RIP PICHU.
Originally posted by HaZeYMan View Post
I WANTED THIS TRANSLATED INTO JAVA FORM. PLEASE!! THANKS


#include <stdio.h>
#include <math.h>

void liqui(int ,int*,int*,int*,int*);

int main()
{
int num1, gallons, quarts, pints, cups;

printf("Enter the number of cups:");
scanf("%2d",&num1);

liquid(num1, &gallons, &quarts, &pints, &cups);

return 0;
}

void liquid(int x, int *gallons, int *quarts, int *pints, int *cups)
{
static int y;
y = x;

if (y >= 16)
{
*gallons = (y / 16);
printf("The number of gallons is %3d\n", *gallons);
}
if (y - (*gallons * 16) >= 4)
{
*quarts = ((y - (*gallons * 16)) / 4);
printf("The number of quarts is %3d\n", *quarts);
}
if ((y - (*gallons * 16) - (*quarts * 4)) >= 2)
{
*pints = ((y - (*gallons * 16) - (*quarts * 4)) / 2);
printf("The number of pints is %3d\n", *pints);
}
if ((y - (*gallons * 16) - (*quarts * 4) - (*pints *2)) < 2 || y == 0)
{
*cups = (y - (*gallons * 16) - (*quarts * 4) - (*pints *2));
printf("The number of cups is %3d\n", *cups);
}
return;
}


If you can't translate this, you need to work more on Java then.

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo