Professional Documents
Culture Documents
} } }
});
} }
JAVA Code for LoginSuccessActvity private void setWallpaper()
JAVA Code for LoginActivity
package com.example.myapplication11; package com.example.myapplication11; {
import androidx.appcompat.app.AppCompatActivity; mytimer.schedule(new TimerTask() {
import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; @Override
public class LoginSuccessActivity extends AppCompatActivity public void run() {
import android.content.Intent; if(prev==1)
{
import android.os.Bundle; @Override protected void onCreate(Bundle savedInstanceState) {
{ drawable=getResources().getDrawable(R.drawable.w1);
import android.view.View; prev=2;
super.onCreate(savedInstanceState); setContentView(R.layout.activity_login_success); }
import android.widget.Button; else if(prev==2)
} {
import android.widget.EditText;
} drawable=getResources().getDrawable(R.drawable.w2);
import android.widget.Toast; prev=3;
4th program Wallpaper }
public class LoginActivity extends AppCompatActivity else if(prev==3)
JAVA Code:
{ package com.example.myapplication; {
EditText emailEditText, passwordEditText; import androidx.appcompat.app.AppCompatActivity; drawable=getResources().getDrawable(R.drawable.w3);
Button loginBtn; import android.app.WallpaperManager; prev=4;
@Override protected void onCreate(Bundle savedInstanceState) import android.graphics.Bitmap; }
{ import android.graphics.drawable.BitmapDrawable; else
super.onCreate(savedInstanceState); import android.graphics.drawable.Drawable; {
setContentView(R.layout.activity_login); import android.os.Bundle; drawable=getResources().getDrawable(R.drawable.w4);
emailEditText = findViewById(R.id.emailEditText); passwordEditText = import android.view.View; prev=1;
findViewById(R.id.passwordEditText); import android.widget.Button; }
loginBtn = findViewById(R.id.loginBtn); import java.io.IOException; Bitmap wallpaper=((BitmapDrawable)drawable).getBitmap();
String registeredEmail = getIntent().getStringExtra("email"); String import java.util.Timer; try {
registeredPassword =getIntent().getStringExtra("password"); import java.util.TimerTask; wpm.setBitmap(wallpaper);
loginBtn.setOnClickListener(new View.OnClickListener() public class MainActivity extends AppCompatActivity }
{ { catch (IOException e)
@Override public void onClick(View v) Button chngwallpaper; {
{ Timer mytimer; e.printStackTrace();
String email = emailEditText.getText().toString(); Drawable drawable; }
String password = passwordEditText.getText().toString(); WallpaperManager wpm; }
if (registeredEmail.equals(email) && registeredPassword.equals(password)) int prev=1; },0,30000);
{ }
Intent intent = new Intent(LoginActivity.this, LoginSuccessActivity.class); @Override }
startActivity(intent); protected void onCreate(Bundle savedInstanceState) {
} super.onCreate(savedInstanceState); 5th program counter value
Else setContentView(R.layout.activity_main);
{ mytimer=new Timer(); JAVA Code:
Toast.makeText(LoginActivity.this, "Invalid Credentials", wpm=WallpaperManager.getInstance(this); package com.example.lbp3;
Toast.LENGTH_SHORT).show(); chngwallpaper=findViewById(R.id.button); import androidx.appcompat.app.AppCompatActivity;
} chngwallpaper.setOnClickListener(new View.OnClickListener() { import android.os.Bundle;
} @Override import android.os.Handler;
}); public void onClick(View v) { import android.view.View;
} setWallpaper(); import android.widget.Button;
{ cout<<"Name="<<s[j].name<<"\n"<<"USN="<<s[j].usn<<"\n" }
cout<<"1.Insert 2.Display 3.Search 4.Delete 5.Exit\n"; <<"Sem="<<s[j].sem<<"\n"<<"Branch="<<s[j].branch<<"\n"; }
cout<<"Enter choice: "; } }
cin>>ch; f1.close(); 6th secondary index
switch(ch) f2.close(); #include<iostream.h>
{ break; #include<string.h>
case 1: f1.open("m1.txt",ios::app); case 4: f1.open("m1.txt",ios::in); #include<fstream.h>
f2.open("mn1.txt",ios::app); f2.open("mn1.txt",ios::in); #include<stdlib.h>
cout<<"Enter no. of students: "; cout<<"Enter USN to delete: "; #include<conio.h>
cin>>k; cin>>usn; int n=0,index=0;
n=n+k; j=p.remove(f1,usn); class student
for(int i=1;i<=k;i++) if(j!=0) {
s[i].insert(f1,f2); { public: char name[20],usn[20],branch[5];
f1.close(); for(i=j;i<n;i++) int sem;
f2.close(); s[i]=s[i+1]; void insert(fstream &f1,fstream &f2)
break; cout<<"Deletion successfull\n"; {
case 2: f2.open("mn1.txt",ios::in); } cout<<"Enter Name: ";
for(i=1;i<=n;i++) n--; cin>>name;
s[i].display(f2); index--; cout<<"Enter USN: ";
f2.close(); f1.close(); cin>>usn;
break; f2.close(); cout<<"Enter Sem: ";
case 3: char usn[20]; f1.open("m1.txt",ios::trunc|ios::app); cin>>sem;
cout<<"Enter USN to search: "; f2.open("mn1.txt",ios::trunc|ios::app); cout<<"Enter Branch: ";
cin>>usn; index=0; cin>>branch;
f1.open("m1.txt",ios::in); for(i=1;i<=n;i++) write(f1,f2);
f2.open("mn1.txt",ios::in); s[i].write(f1,f2); }
int j=p.search(f1,usn); f1.close(); void write(fstream &f1,fstream &f2)
if(j!=0) f2.close(); {
{ break; f1<<++index<<"\t"<<name<<"\n";
cout<<"Record found & Details are\n"; default:exit(0); f2<<name<<"\t"<<usn<<"\t"<<sem<<"\t"<<branch<<"\n";
} clrscr(); f1.open("m.txt",ios::in);
void display(fstream &f2) f1.open("m.txt",ios::trunc); f2.open("mn.txt",ios::in);
{ f2.open("mn.txt",ios::trunc); int j=p.search(f1,name);
f2>>name>>usn>>sem>>branch; f1.close(); if(j!=0)
cout<<name<<"\t"<<usn<<"\t"<<sem<<"\t"<<branch<<"\n"; f2.close(); {
} for(;;) cout<<"Record found & Details are\n";
int search(fstream &f1,char key[20]) { cout<<"Name="<<s[j].name<<"\n"<<"USN="<<s[j].usn<<"\n"
{ cout<<"1.Insert 2.Display 3.Search 4.Delete 5.Exit\n"; <<"Sem="<<s[j].sem<<"\n"<<"Branch="<<s[j].branch<<"\n";
int i,x; cout<<"Enter choice: "; }
for(i=1;i<=n;i++) cin>>ch; f1.close();
{ switch(ch) f2.close();
f1>>x>>name; { break;
if(strcmp(name,key)==0) case 1: f1.open("m.txt",ios::app); case 4: f1.open("m.txt",ios::in);
return i; f2.open("mn.txt",ios::app); f2.open("mn.txt",ios::in);
} cout<<"Enter no. of students: "; cout<<"Enter name to delete: ";
cout<<"Record not found\n"; cin>>k; cin>>name;
return 0; n=n+k; j=p.remove(f1,name);
} for(int i=1;i<=k;i++) if(j!=0)
int remove(fstream &f1,char key[20]) s[i].insert(f1,f2); {
{ f1.close(); for(i=j;i<n;i++)
int i; f2.close(); s[i]=s[i+1];
i=search(f1,key); break; cout<<"Deletion successfull\n";
return i; case 2: f2.open("mn.txt",ios::in); }
} for(i=1;i<=n;i++) n--;
}; s[i].display(f2); index--;
void main() f2.close(); f1.close();
{ break; f2.close();
fstream f1,f2; case 3: char name[20]; f1.open("m.txt",ios::trunc|ios::app);
student s[20],p; cout<<"Enter name to search: "; f2.open("mn.txt",ios::trunc|ios::app);
int ch,k=0,i; cin>>name; index=0;
for(i=1;i<=n;i++) cin>>m; if((!out3)||(!out1)||(!out2))
s[i].write(f1,f2); cout<<"\nEnter the names in assending order \n"; {
f1.close(); for(i=0;i<m;i++) cout<<"Unable to open one of the file";
f2.close(); { getch();
break; cin>>name; exit(0);
default:exit(0); out1<<name; }
} out1<<'\n'; clrscr();
} } m=0;
} cout<<"Enter the number of names you want to enter in file2 "; n=0;
th
7 program list and match the names in single loop cin>>n; while(!out1.eof())
#include<stdio.h> cout<<"\nEnter the names in assending order \n"; {
#include<stdlib.h> for(i=0;i<n;i++) out1.getline(list1[m],20,'\n');
#include<string.h> { cout<<list1[m]<<"\t";
#include<conio.h> cin>>name; m++;
#include<fstream.h> out2<<name; }
#include<iostream.h> out2<<'\n'; cout<<endl;
void writeLists() } while(!out2.eof())
{ out1.close(); {
fstream out1,out2; out2.close(); out2.getline(list2[n],20,'\n');
int i,m,n; } cout<<list2[n]<<"\t";
char name[20]; void main() n++;
out1.open("file1.txt",ios::out); { }
out2.open("file2.txt",ios::out); char list1[100][20],list2[100][20]; m--;
if( (!out1) || (!out2) ) int i,j,m,n; n--;
{ clrscr(); i=0;
cout<<"Unable to open one of the list files\n"; fstream out1,out2,out3; j=0;
getch(); writeLists(); cout<<"\nElements common to both files are\n";
exit(0); out1.open("file1.txt",ios::in); while(i<m&&j<n)
} out2.open("file2.txt",ios::in); {
cout<<"Enter the number of names you want to enter in file1 "; out3.open("file3.txt",ios::out); if(strcmp(list1[i],list2[j])==0)
else 31 }
\ Cyclomatic Complexity
} V(G) =e-n+2p
Where,
Cyclomatic Complexity e is number of edges in DD-Path graph.
V(G) =e-n+2p n is number of nodes in DD-Path graph.
or p is number of regions connected.(always 1)
V(G) =e-n+p (for closed closed graph) Number of linearly independent paths (Test cases) for a given graph G = 26-19+2(1)
Where, = 7+2
e is number of edges in DD-Path graph. = 9 Test cases
n is number of nodes in DD-Path graph.
p is number of regions connected.(always 1)
Number of linearly independent paths (Test cases) for a given graph G = 23-17+(1)
= 6+1
= 7 Test cases
12 th program absolute letter grading
#include<stdio.h>
#include<conio.h>
A. 1 int main()
2{
3 float per;
4 char grade;
5 printf("enter the percentage\n");
6 scanf("%f",&per);
B. 7 if(per>=90)
C. 8 grade='a';
D. 9 else if((per>=80) && (per<90))
E. 10 grade='b';
F. 11 else if((per>=70) && (per<80))
G. 12 grade='c';
H. 13 else if((per>=60) && (per<70))
I. 14 grade='d';
J. 15 else grade='e';
K. 16 switch(grade)
L. 17 {
M. 18 case 'a':printf("excellent\n");
19 break;
N. 20 case 'b':printf("very good\n");
21 break;
O. 22 case 'c':printf("good\n");
23 break;
P. 24 case 'd':printf("above average\n");
25 break;
Q. 26 case 'e':printf("satisfactory\n");
27 break;
R. 28 }
S. 29 printf("the percentage is %f and the grade is %c\n",per,grade);
30 return 0;