package abc; import java.util.*; public class TransformCharacters { public static String changeCharacters(String string) { for (int i = 0; i < string.length(); i++) { char ch = string.charAt(i); { if (Character.isUpperCase(ch)) string.replace(ch, '1'); } } return string; } public static void main(String[] args) { // TODO Auto-generated method stub String s = "oYoroCoroSor"; System.out.println(changeCharacters(s)); } } Task was to replace all capital letters with 1. The logic i used seems fine, but i am not getting the desired output. the function returns the same string which has been sent to it, I have used Simple print statements at all steps …

Member Avatar
Member Avatar
+0 forum 1

CREATE TABLE Artist ( A_id INT NOT NULL, A_song varchar(100), A_name varchar(100), PRIMARY KEY(A_id,A_song) ); CREATE TABLE Instrument ( I_id int NOT NULL, I_keys varchar(100), I_name varchar(100), PRIMARY KEY(I_id,I_name), a_id int NOT NULL, FOREIGN KEY (a_id) references Artist(A_id) ); CREATE TABLE Song ( S_id int NOT NULL PRIMARY KEY, S_vocalist varchar(100), S_nom int NOT NULL, S_name varchar(100), FOREIGN KEY (S_name) references Artist(A_song), S_inst varchar(100), FOREIGN KEY (S_inst) references Instrument(I_name), a_id int NOT NULL, FOREIGN KEY (a_id) references Artist(A_id) ); I am getting this error: "ERROR 1215 (HY000): Cannot add foreign key constraint" probably on this part of the code : …

Member Avatar
Member Avatar
+0 forum 2

In this main class I used a **ListIterator** variable, **hasnext()** and **next()** method to print LIST memebers. I created litr variable of ListIterator, I performed some functions on the list i.e, sorting(ascending and descending) etc. I used the same litr variable and a while loop for outputing the list again and again(after making changes in it), this output method works for the first time only, later on it is not showing the desired output. See attachments for output snapshot. Thanks public static void main(String args[]) { Publisher pub1 = new Publisher("1000", "Smith", 3); Publisher pub2 = new Publisher("4001", "Jones", 8); …

Member Avatar
Member Avatar
+0 forum 4

**Create a class Employee with name, Id and salary as data members. Provide appropriate constructors, set, get and display methods in the class. In the main program, use a do-while loop to enter data for employees as long as the user desires and save all data to a file. Once the user is done with data entry, read the data for employees from the file and display the information of each employee.** // Lab_13_A.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> #include<conio.h> #include<string> #include<fstream> using namespace std; class emp { private: int id,sal; string …

Member Avatar
Member Avatar
+0 forum 1

#include "stdafx.h" #include<iostream> #include<conio.h> #include<string> using namespace std; //--------------------------------Structures--------------------------------// struct datee { int month; int days; int years; }; struct book { string bookname; string bookpublisher; string authorName; int copies; int price; int edition; datee date; }; //---------------------------Function Prototypes----------------------------// void titleheader(); void menu(); void addbook(book b[],int i); void display(book b[],int j); void edit(book b[], int a); void search(book b[],int a); void del (book b[],int a); //--------------------------Main Function---------------------------------// char op; int _tmain(int argc, _TCHAR* argv[]) { book * pt; int ch; static int a; const int size=10; book b[size]; book array[size]; loop: titleheader(); menu(); cout<<"\nPress option key to activate the required …

Member Avatar
Member Avatar
+0 forum 5

**CODE** #include "stdafx.h" #include<iostream> #include<conio.h> #include<string> #include<fstream> using namespace std; //---------------------------Function Prototypes----------------------------// void titleheader(); void menu(); void addbook(); void display(); //--------------------------Main Function---------------------------------// int _tmain(int argc, _TCHAR* argv[]) { int op; titleheader(); menu(); cout<<"\nPress option key to activate the required function: "; cin>>op; switch (op) { case 1: { system("cls"); titleheader(); cout<<"\n"; addbook(); system ("pause"); cin.get(); system("cls"); break; } case 2: { system("cls"); titleheader(); display(); system ("pause"); cin.get(); system("cls"); break; } default : { exit (0); } } getch(); } //************************************ END of main() and Functions Bodies are given below. *********************************************\\ void titleheader() { cout<<"\n ------------------------------------------------------------------------------ "<<endl; cout<<" **** Book Store …

Member Avatar
Member Avatar
+0 forum 4

CODE #include "stdafx.h" #include<iostream> #include<conio.h> #include<string> #include<fstream> using namespace std; //---------------------------Function Prototypes----------------------------// void titleheader(); void menu(); void addbook(); void display(); //--------------------------Main Function---------------------------------// int _tmain(int argc, _TCHAR* argv[]) { int op; titleheader(); menu(); cout<<"\nPress option key to activate the required function: "; cin>>op; switch (op) { case 1: { system("cls"); titleheader(); cout<<"\n"; addbook(); system ("pause"); cin.get(); system("cls"); break; } case 2: { system("cls"); titleheader(); display(); system ("pause"); cin.get(); system("cls"); break; } default : { exit (0); } } getch(); } //************************************ END of main() and Functions Bodies are given below. *********************************************\\ void titleheader() { cout<<"\n ------------------------------------------------------------------------------ "<<endl; cout<<" **** Book Store …

Member Avatar
Member Avatar
+0 forum 3

The End.