Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Could someone fix my code error package websitesusers; public class WebsiteUsers.java { public static User createUser(String name,String email,double data) { User a = new User();

Could someone fix my code error

package websitesusers;

public class WebsiteUsers.java {

public static User createUser(String name,String email,double data) { User a = new User(); a.setName(name); a.setEmail(email); a.setDataAllowance(data); return a; }

public static void printWebsite(Website web) { System.out.println("Name: " + web.getName()); System.out.println("Number of users: " + web.getUsersSize()); for(int i=0;i

public static void main(String[] args) { Website web1 = new Website(); web1.setName("Google"); web1.addUser(createUser("ktw","abc",2.0),5.0); web1.addUser(createUser("tony","abcd",12.0),50.0); web1.addUser(createUser("kerpink","abcdef",20.0),55.0);

Website web2 = new Website(); web2.setName("Yahoo"); web2.addUser(createUser("John","abc",12.0),5.0); web2.addUser(createUser("Moe","abd",5.0),10.0); web2.addUser(createUser("Smith","def",25.0),15.0);

System.out.println("Initial data of website 1:"); printWebsite(web1);

System.out.println("Initial data of website 2:"); printWebsite(web2); web1.removeUser(0); web1.removeUser(1); System.out.println("Data of website 1 after removing two users: "); printWebsite(web1);

web2.removeUser(0); System.out.println("Data of website 2 after removing one users: "); printWebsite(web2); } }

public void removeUser(int index){

for(int i = index + 1; i < size; i++){ users[i - 1] = users[i]; extraData[i - 1] = extraData[i]; } size--; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions