ok i have a computer science assignment due soon and its concerning java. for the assignment, we must make flags representing different countries. for example, i have to make the italian flag so i need to create a grid thats one thirds green, one thirds white and one thirds red to represent that flag. the user will input a certain width and height that are going to be used to create the grid. the project guidelines have certain conditions that we must add in order for the flag to be shown in output. if the conditions in the guidelines arent valid, i would have to create an error flag (which i know how to do). like here is a condition for the italian flag i just mentioned:
Its height must be a multiple of 3, and its width must be exactly twice as large as its height to be valid.
how would i format that into a conditional. i dont get how to make an if statement (or whatever) for a multiple. let me give you a very brief/simple explanation of my code so far:
Print: "Choose 1 for Italy, 2 for Chile, 3 for Switzerland..."
choice.scan nextINT()
Print: "enter width and height"
width.scan nextINT()
height.scan nextINT
// width and height are my 2 variables
if (choice == 1) {
/* in this area i have my code to create the flag based on the requirements (1/3 is green, 1/3 is white...)
*/
}
(end)
so i am guessing i need an if statement inside that first if statement with an expression representing those guidelines i mentioned above. (here they are again: its height must be a multiple of 3, and its width must be exactly twice as large as its height to be valid). and then i figure i need to put an else statement to the new if statement that will produce the error flag if that condition i need help with is not true. so yeah. i hope that wasnt too confusing. pretty much i need to figure out how to express this statement with logical operators:
its height must be a multiple of 3, and its width must be exactly twice as large as its height to be valid.
the multiple part is confusing me the most. thanks guys.
i'm guessing the part where it says width must be exactly twice as large as its height will look like this:
if ( width = height * 2)
and the multiple part must be an && statement attached to that if condition i wrote.