so we have a big project and i already did the cartesianproduct portion now i'm stuck on creating a venn diagram application that should ask for the user to enter specifications like labels dancing singing , etc. and then how many for each 23 students like dancing, 10 like singing 20 like both singing and dancing total students are 25 . display students who dont like singing or who does not like singing, dancing... I just need help gettign started i looked online google nothing about doing this type of venn diagram i only see about shading or what have you. any advice would be appreciated.

I know i would do Jlabels but they can enter different numbers each tiem the program runs would i do a a switch so if they choose choice 1 to display who only likes to sing etc. ?

Edited 5 Years Ago by ITHope: n/a

Do you want to display the whole complete Venn diagram? If so, you would need Graphics or Graphic2D to draw the diagram for you. If you want it to be dynamic, you need to redraw (paint) the panel over again once you get a value and computed.

ok decided to do code first in java then maybe you can get an idea of what i was asking and il also post what the professor is asking for

import java.util.*;

public class studentmusicalinterest
{
static Scanner console = new Scanner(System.in);

public static void main(String[] args)
{
int likejazz, likerock, likeclassical, likeclassical_jazz, likeclassical_rock, likerock_jazz;
int likerock_jazz_classical, students;
int jazz,rock,classical,classical_jazz,classical_rock,rock_jazz,rock_jazz_classical,  dislikeclassical_rock_jazz;


System.out.print(" How many students: " );
students = console.nextInt();
System.out.print(" How many students like jazz music: " );
likejazz = console.nextInt();
System.out.print(" How many students like rock music: " );
likerock = console.nextInt();
System.out.print(" How many students like classical music: " );
likeclassical = console.nextInt();
System.out.print(" How many students like classical and jazz music: " );
likeclassical_jazz = console.nextInt();
System.out.print(" How many students like classical and rock music: " );
likeclassical_rock = console.nextInt();
System.out.print(" How many students like rock and jazz music: " );
likerock_jazz = console.nextInt();
System.out.print(" How many students like rock, jazz, and classical music: " );
likerock_jazz_classical = console.nextInt();


System.out.println("This is for the Venn Diagram Break down");
//start from the center and work your way out

rock_jazz_classical = likerock_jazz_classical;
System.out.println("Students that like all three: " + rock_jazz_classical);
rock_jazz = likerock_jazz - rock_jazz_classical;
System.out.println("Students that like rock and jazz: " + rock_jazz);
classical_rock = likeclassical_rock - rock_jazz_classical;
System.out.println("Students that like classical and rock: " + classical_rock);
classical_jazz = likeclassical_jazz - rock_jazz_classical;
System.out.println("Students that like classical and jazz: " + classical_jazz);
classical = likeclassical - (rock_jazz_classical + classical_rock + classical_jazz);
System.out.println("Students that like classical music: " + classical);
rock = likerock - (rock_jazz_classical + classical_rock + rock_jazz);
System.out.println("Students that like rock music: " + rock);
jazz = likejazz - (rock_jazz_classical + classical_jazz + rock_jazz);
System.out.println("Students that like rock music: " + jazz);


System.out.println("This is for the display after the Venn Diagram breakdown");
// displays how many students like rock only
//display how many students do not like rock, jazz, and classical

System.out.println(" How many students like only rock music?: " + rock);
dislikeclassical_rock_jazz = students - (rock_jazz_classical + rock_jazz + classical_rock + classical_jazz + classical + rock + jazz);
System.out.println(" How many students dislike rock, jazz and classical music?: " + dislikeclassical_rock_jazz);

}
}

VennDiagram(J,R, C)
•Should have a way to ask the user for the specifications similar to the numbers in the graph below. The user may want to enter different sets of numbers each time the program is ran.Should display how many students like rock only.Should display how many students who do not like jazz, rock, or classical if there are 100 (You must ask the user how many students) students involved.

*your functions should be stored in an external class*

i guess my question is how to create the actual picture of the venn diagram with the components broken down like i have done in just plain java code in prev. post

What is your exact question? I get your assignment, please ask one.

I think a previous answer has already told it: you need to make a GUI. Have you ever used Swing to make a GUI?

You will need the following:
- a class that makes the GUI and shows it
- that class should override paintComponent(Graphics g)
- add your drawing code to the overridden function:
- Make circles for all the groups of people
- make labels, which will show the number of people in the group, or each group.

If you have any specific questions, please ask, we'll try to answer them.

thank you so much but my teacher just told us we do not have to actually draw the out put anymore. but i still have to convert it to an applet/gui and also havefunctions in external classes. im goign to work on it tonight and post it tomorrow morning for help. thanks

I think a previous answer has already told it: you need to make a GUI. Have you ever used Swing to make a GUI?

You will need the following:
- a class that makes the GUI and shows it
- that class should override paintComponent(Graphics g)
- add your drawing code to the overridden function:
- Make circles for all the groups of people
- make labels, which will show the number of people in the group, or each group.

If you have any specific questions, please ask, we'll try to answer them.

This article has been dead for over six months. Start a new discussion instead.