Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

how would i print out the arrays Names and Gifts it keeps giving me an error when I try to use Arrays.toString(name)); import java.util.Scanner; import

how would i print out the arrays Names and Gifts it keeps giving me an error when I try to use Arrays.toString(name));

import java.util.Scanner; import java.util.Arrays; public class DSassignment1 { void arrays() { Scanner kb = new Scanner(System.in); String[] names = new String[15];

System.out.println("enter friends names | type *END* when done"); for(int i = 0; i < names.length; i++){

String in = kb.nextLine(); names[i] = in; if(in.equals("*END*")){ break;} }

String[] gifts = new String[15]; System.out.println("enter gift names | type *END* when done"); for(int j = 0; j < gifts.length; j++){ String in = kb.nextLine(); gifts[j] = in; if(in.equals("*END*")){ break;} } for( int j=1; j 0 && names[i-1].compareTo(x) > 0) { names[i] = names[i-1]; i--; } names[i] = x; } }

public static void main(String[] args) { DSassignment1 lab = new DSassignment1(); lab.arrays(); } }

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

Database Design Using Entity Relationship Diagrams

Authors: Sikha Saha Bagui, Richard Walsh Earp

3rd Edition

103201718X, 978-1032017181

More Books

Students also viewed these Databases questions

Question

6. Is all Internet training the same? Explain.

Answered: 1 week ago